2021, XIII Donald Knuth Annual Programming Contest by ESCOM-IPN
A. Coffee Bar
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

One of the favorite places of students in ESCOM campus is the coffee bar located in the first floor of Building $$$1$$$. In that coffee bar you can buy some snacks and beverage while waiting for a professor or during the break between classes.

The ciabatta sandwiches are undoubtedly the most popular product there. They offer various ingredients for the ciabatta sandwiches: ham, sausage, turkey, beef, tuna, etc.

Today we celebrate the $$$28$$$th Anniversary of ESCOM. Because of that, the problem setters have decided to give you the chance to simulate an order in the coffee bar of ESCOM.

You are given a menu containing $$$n$$$ ingredients. Each ingredient is given as a string of lowercase and uppercase letters without spaces. You need to choose one ingredient (can be any of them) and print it.

Input

The first line contains an integer $$$n$$$ ($$$1 \leq n \leq 10$$$) $$$-$$$ the number of ingredients of ciabatta sandwiches offered in the menu of the coffee bar.

The following $$$n$$$ lines contain the ingredients offered. Each ingredient is represented as a string consisting of lowercase and uppercase letters. The length of each string is at most $$$10$$$.

Output

Print a single string $$$-$$$ the ingredient that you would like to order.

If there are multiple answers, you can print any of them.

Examples
Input
5
Ham
Sausage
Turkey
Beef
Tuna
Output
Sausage
Input
1
Cheese
Output
Cheese
Note

The words are case sensitive. For example, "Sausage" is different to "sausage" or "SaUsAgE"

We don't guarantee that you will actually get a ciabatta sandwich.

B. Huron Jam
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Huron Jam is a competition for university students organized by the popular competitive programming site HuronForces. The participants form teams of two students from the same university and take part in multiple rounds.

Edgardo is responsible for registering the teams for ESCOM. There are $$$n$$$ ($$$n$$$ is an even number) students in ESCOM available to compete in Huron Jam and Edgardo will divide them in $$$\frac{n}{2}$$$ teams of two people to participate in the competition.

Each student has a skill level $$$a_i$$$. If the students with skill levels $$$x$$$ and $$$y$$$ form a team, then the imbalance of that team would be considered to be $$$|x-y|$$$. Edgardo knows that maintaining the imbalance of the teams as low as possible is important for the success of the university in the competition, so he wants to select the teams while minimizing the total imbalance of them. The total imbalance is defined as the sum of the imbalance of the $$$\frac{n}{2}$$$ teams.

Help Edgardo to find the minimum total imbalance that he can achieve when dividing the students in $$$\frac{n}{2}$$$ teams. Note that each student must be in exactly one team.

Recall that $$$|x|$$$ is defined to be the absolute value of $$$x$$$. In other words, if $$$x$$$ is an integer number, then $$$|x|=x$$$ if $$$x \geq 0$$$ and $$$|x|=-x$$$ when $$$x \lt 0$$$.

Input

The first line contains an integer $$$n$$$ ($$$2 \leq n \leq 1000$$$ and $$$n$$$ is even) $$$-$$$ the number of available students in ESCOM.

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ in increasing order ($$$1 \leq a_1 \leq a_2 \leq \dots \leq a_n \leq 1000$$$) $$$-$$$ the skill level of the students in ESCOM.

Output

In the first line print a single integer $$$-$$$ the minimum possible total imbalance.

Examples
Input
2
1 1000
Output
999
Input
6
1 3 4 6 7 32
Output
29
Input
8
1 1 2 3 3 6 8 10
Output
6
Input
4
1 2 3 4
Output
2
Input
34
512 514 557 565 570 574 588 601 620 623 625 626 645 659 674 680 734 740 775 778 786 793 836 856 863 911 925 926 929 933 941 947 958 984
Output
172
Note

In the first example, there are $$$2$$$ students, so Edgardo can form only one team: a team formed with students with skill level $$$1$$$ and $$$1000$$$. The total imbalance is $$$|1-1000|=999$$$.

In the second example, there are $$$6$$$ students and Edgardo need to form $$$\frac{6}{2}=3$$$ teams. He can select students with skill level $$$6$$$ and $$$4$$$ for the first team, students with skill level $$$7$$$ and $$$32$$$ for the second team and students with skill level $$$3$$$ and $$$1$$$ for the third team. The total imbalance is equal to $$$|6-4|+|7-32|+|3-1|=29$$$. In any other division of the students in $$$3$$$ teams the total imbalance will be greater or equal to $$$29$$$.

C. Ultimate Huron Sorting
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

One year after participating in the Donald Knuth 2020 contest and solving successfully the problem Huron Sorting, Enya started to think about new algorithms to sort permutations. After some thinking, she came with a novel idea: the Ultimate Huron Sorting.

Let's define a permutation as an array of size $$$n$$$, such that all the numbers between $$$1$$$ and $$$n$$$ appears exactly once in the permutation and it does not have any repeated element. For example, $$$[1,2,3,4]$$$ and $$$[3,1,4,2]$$$ are permutations of size $$$4$$$, but $$$[1,1,3,4]$$$ and $$$[3,2,1,5]$$$ are not.

To sort a permutation $$$A=[a_1, a_2, \dots, a_n]$$$ of size $$$n$$$ using the Ultimate Huron Sorting, Enya chooses an integer $$$x$$$, such that $$$1 \leq x \leq n$$$ at the beginning, and then perform the following operation any number of times until the permutation is sorted in increasing order:

  • Choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \leq i,j \leq n$$$), such that $$$i \neq x$$$ and $$$j \neq x$$$, and swap the elements in the $$$i$$$-th and $$$j$$$-th positions of the permutation. In other words, Enya can choose any pair of indices different to the chosen $$$x$$$ and swap them.

Note that $$$x$$$ is always chosen at the beginning of the algorithm and does not change during its execution.

Enya quickly realized that this algorithm may not work for all values of $$$x$$$. Help her to find how many values of $$$x$$$ she can choose, such that she can apply some operations (possibly zero) to sort the permutation in increasing order.

Input

The first line contains an integer $$$n$$$ ($$$1 \leq n \leq 100$$$) $$$-$$$ size of the permutation.

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq n$$$) $$$-$$$ the elements of the permutation.

Output

Print a single integer $$$-$$$ the number of suitable values of $$$x$$$.

Examples
Input
5
1 2 3 4 5
Output
5
Input
2
2 1
Output
0
Input
5
2 3 5 4 1
Output
1
Input
6
5 2 3 4 6 1
Output
3
Note

In the first example, the permutation is already sorted, so we can choose any value of $$$x$$$.

In the second example, we need to swap the first element with the second element to sort the permutation. If $$$x=1$$$, we can't choose the first element to sort the permutation. If $$$x=2$$$, we can't choose the second element to sort the permutation.

In the third example, the only value of $$$x$$$ that we can choose to sort the permutation is $$$4$$$. Let's see how we can sort this permutation with $$$x=4$$$:

  1. $$$[\textbf{2},3,5,\underline{4},\textbf{1}]$$$ - choose $$$i=1$$$ and $$$j=5$$$, and swap the element in those positions. We can choose those values since $$$x \neq 1$$$ and $$$x \neq 5$$$.
  2. $$$[1,\textbf{3},5,\underline{4},\textbf{2}]$$$ - choose $$$i=2$$$ and $$$j=5$$$, and swap the element in those positions.
  3. $$$[1,2,\textbf{5},\underline{4},\textbf{3}]$$$ - choose $$$i=3$$$ and $$$j=5$$$, and swap the element in those positions.
  4. $$$[1,2,3,\underline{4},5]$$$ - now the permutation is sorted in increasing order and we terminate the algorithm successfully.

You can try to order the permutation choosing any other value for $$$x$$$ and see that it is not possible.

D. Sightseeing with Friends
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

For summer vacations $$$n$$$ friends chose to go to a popular sightseeing place at the top of a hill. Once they had reached their destination, they decided to take a photo of all of them in a line. For this they asked a tourist to help them on taking the photo. The tourist nervously agreed, since he doesn't know how to use the camera properly. Not wanting to mess up, the tourist took $$$m$$$ photos of the group of friends, where in each one of them only a continuous sequence of friends is visible in the photo. This means that for the $$$i$$$-th photo, only the friends indexed from $$$l_i$$$ to $$$r_i$$$ (indexing starting from the left) can be seen in the photo.

The group of friends didn't know about this issue until they returned from the trip. Now $$$q$$$ pairs of friends want to see if from all of the photos that were taken, both of the friends appear in at least one of them. This means that if while taking the photo, the friends were standing at the $$$u$$$-th and $$$v$$$-th position respectively, they want to see if there is a photo $$$p$$$ where $$$l_p \leq u,v \leq r_p$$$.

Input

The first line contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \leq n, m, q \leq 10^6$$$) $$$-$$$ number of friends, number of photos and the number of pairs of friends.

Each of the following $$$m$$$ lines contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \leq l_i \leq r_i \leq n$$$) $$$-$$$, the range of friends in the $$$i$$$-th photo.

Each of the following $$$q$$$ lines contain two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq n$$$ and $$$u \neq v$$$) $$$-$$$, the pairs of friends.

Output

The output should contain the answer for each of the $$$q$$$ queries in order. Print Yes (case insensitive) if the respective pair of friends appears in at least one photo. Otherwise print No (case insensitive).

As input/output can reach huge size, we recommend to use fast input/output methods. For example, prefer to use scanf/printf in C++ instead of cin/cout.

Examples
Input
6 4 3
2 5
1 2
3 6
4 5
1 3
4 5
4 6
Output
No
Yes
Yes
Input
10 5 6
3 7
4 5
2 7
9 10
1 3
1 8
4 2
7 10
5 3
2 5
8 6
Output
No
Yes
No
Yes
Yes
No
Note

In the first example, the tourist took $$$4$$$ photos:

  1. In the first photo appear friends 2, 3, 4, and 5.
  2. In the second photo appear friends 1 and 2.
  3. In the third photo appear friends 3, 4, 5 and 6.
  4. In the fourth photo appear friends 4 and 5.

There are $$$3$$$ pair of friends:

  1. The first pair is formed by friends 1 and 3. They don't appear together in any photo, so the answer is no.
  2. The first pair is formed by friends 4 and 5. They appear together in the first, third and fourth photos, so the answer is yes.
  3. The first pair is formed by friends 4 and 6. They appear together in the first and third photos, so the answer is yes.

E1. Coins Game (easy version)
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

This is the easy version of this problem. The only difference is the constraint of $$$n$$$.

Palindromito is playing with his new $$$n$$$ coins, all of them are lined up on his desk numbered from $$$1$$$ to $$$n$$$, each showing Águila ($$$A$$$) or Sol ($$$S$$$). The goal of the game is to finish with all the coins showing Sol, and the only possible move is: if there are $$$k$$$ coins showing Águila and $$$k \geq 1$$$, then he flips the $$$k^{th}$$$ coin over; otherwise the game ends.

For example, if he start with 3 coins showing $$$SAS$$$, in 3 steps he finishes the game: $$$SAS \to AAS \to ASS \to SSS$$$. It can be shown that for any configuration of $$$n$$$ coins, the number of steps until the game is over is always finite.

Palindromito wants to find the average number of steps over all $$$2^n$$$ possible configurations of his coins, please help him. This value is always a rational number.

Input

In the only line you'll be given the positive integer $$$n$$$ ($$$1 \leq n \leq 20$$$).

Output

Suppose that the answer has the form $$$\frac{a}{b}$$$, where $$$a,b \gt 0$$$ are positive integers and $$$\gcd(a,b)=1$$$. Print $$$a/b$$$, i.e., the two numbers separated by a slash $$$/$$$.

Examples
Input
1
Output
1/2
Input
2
Output
3/2
Input
3
Output
3/1

E2. Coins Game (hard version)
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

This is the hard version of this problem. The only difference is the constraint of $$$n$$$.

Palindromito is playing with his new $$$n$$$ coins, all of them are lined up on his desk numbered from $$$1$$$ to $$$n$$$, each showing Águila ($$$A$$$) or Sol ($$$S$$$). The goal of the game is to finish with all the coins showing Sol, and the only possible move is: if there are $$$k$$$ coins showing Águila and $$$k \geq 1$$$, then he flips the $$$k^{th}$$$ coin over; otherwise the game ends.

For example, if he start with 3 coins showing $$$SAS$$$, in 3 steps he finishes the game: $$$SAS \to AAS \to ASS \to SSS$$$. It can be shown that for any configuration of $$$n$$$ coins, the number of steps until the game is over is always finite.

Palindromito wants to find the average number of steps over all $$$2^n$$$ possible configurations of his coins, please help him. This value is always a rational number.

Input

In the only line you'll be given the positive integer $$$n$$$ ($$$1 \leq n \leq 10^9$$$).

Output

Suppose that the answer has the form $$$\frac{a}{b}$$$, where $$$a,b \gt 0$$$ are positive integers and $$$\gcd(a,b)=1$$$. Print $$$a/b$$$, i.e., the two numbers separated by a slash $$$/$$$.

Examples
Input
1
Output
1/2
Input
2
Output
3/2
Input
3
Output
3/1

F. Moss Growing
time limit per test
2 s
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a squared Petri dish represented by a grid of size $$$N * N$$$. Rows are numbered from $$$1$$$ to $$$N$$$ from top to bottom and columns are numbered from $$$1$$$ to $$$N$$$ from left to right. The cell located in the intersection between the $$$x$$$-th row and $$$y$$$-th column is denoted by the coordinates $$$(x,y)$$$.

There are $$$M$$$ small patches of moss initially. The $$$i$$$-th patch is located in the coordinates $$$(x_i,y_i)$$$. During the next days, the patches of moss will extend to the 8 neighboring cells day by day. That is, if in the $$$j$$$-day the cell $$$(x,y)$$$ is occupied, then during the $$$(j+1)$$$-th day the cells $$$(x-1,y-1)$$$, $$$(x-1,y)$$$, $$$(x-1,y+1)$$$, $$$(x,y-1)$$$, $$$(x,y+1)$$$, $$$(x+1,y-1)$$$, $$$(x+1,y)$$$ and $$$(x+1,y+1)$$$ will be occupied, as long as they are inside the grid.

How many days will pass for all cells to be occupied by the patches of moss?

Input

The first line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \leq N \leq 10^{18}$$$ and $$$1 \leq M \leq min(N*N, 1000)$$$) $$$-$$$ size of the grid and number of initial patches of moss.

The next $$$M$$$ lines contain two integers each $$$x_i$$$ and $$$y_i$$$ ($$$1 \leq x_i, y_i \leq N$$$) $$$-$$$ the coordinates of the patches.

It is guaranteed that all the coordinates are different.

Output

Print a single integer $$$-$$$ number of days that will pass for all cells to be occupied.

Examples
Input
6 3
3 5
4 2
2 3
Output
3
Input
1000000000000000000 1
1 1
Output
999999999999999999
Note

You can see the explanation of the first example in the following images:

Note that the initial day is considered to be day 0.

G. Special Bracelets
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

To celebrate their first anniversary together, Alan and Tafnes will make two bracelets as a present to remember each other in the distance. They bought $$$m+n$$$ beads, each with a lowercase letter written in them. Alan will take any $$$m$$$ beads to make his bracelet (let's call it $$$B_A$$$) and Tafnes will take the remaining $$$n$$$ beads to make her bracelet (let's call it $$$B_T$$$). Since this couple is very weird and wonderful, $$$m$$$ and $$$n$$$ will always be prime numbers.

A bracelet is a circular arrangement of strung beads equally spaced which can be represented as a string. Let $$$C$$$ and $$$D$$$ be bracelets, we consider that $$$C \neq D$$$ if bracelet $$$C$$$ cannot be obtained from bracelet $$$D$$$ by rotating it by any angle.

So, Alan an Tafnes are now wondering: how many distinct pairs of bracelets $$$(B_A, B_T)$$$ can they obtain? The beads in each bracelet can be strung in any order they want, and the pair $$$(B_A, B_T)$$$ is to be considered distinct from the pair $$$(B_T, B_A)$$$ unless $$$B_A=B_T$$$.

Input

The first line contains two prime positive integers $$$m$$$ and $$$n$$$ ($$$2 \leq m, n \leq 18002$$$, $$$m+n \leq 18002$$$) — the number of beads they bought.

The second line contains a string of length $$$m+n$$$ consisting only of lowercase English letters — the beads they bought.

Output

Print a single integer — the number of distinct pairs of bracelets $$$(B_A, B_T)$$$. Since this number can be very large, print it modulo the prime number $$$515011997$$$.

Examples
Input
2 2
abcd
Output
6
Input
3 7
aabeinottt
Output
14640
Note

In the first example, they can obtain the following six pairs of bracelets: $$$(ab, cd)$$$, $$$(ac, bd)$$$, $$$(ad, bc)$$$, $$$(bc, ad)$$$, $$$(bd, ac)$$$ and $$$(cd, ab)$$$. For example, note that the pair $$$(ca, bd)$$$ is the same as $$$(ac, bd)$$$ because $$$ca$$$ is a rotation of $$$ac$$$.

H. Truth Table
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Consider infix boolean expressions, consisting of:

  • Single lowercase letters from the english alphabet for variable names, which can be equal to $$$0$$$ (FALSE) or $$$1$$$ (TRUE)
  • Unary NOT operator: $$$\sim$$$
  • Binary AND operator: &
  • Binary XOR operator: ^
  • Binary OR operator: |
  • Binary NAND operator: #
  • Binary XNOR operator: %
  • Binary NOR operator: $
  • Opening and closing parenthesis: ( and )
  • No spaces

Now let's define the operator precedence for binary operators: let $$$p_\star$$$ be the precedence for the operator $$$\star$$$, the lower $$$p_\star$$$ is, the higher its precedence is. For example, consider the consider the expression $$$a \star_1 b \star_2 c$$$:

  • If $$$p_{\star_1} \lt p_{\star_2}$$$, then $$$\star_1$$$ has higher precedence than $$$\star_2$$$ and is evaluated first, so the expression can be read as $$$(a \star_1 b) \star_2 c$$$.
  • If $$$p_{\star_1} \gt p_{\star_2}$$$, then $$$\star_2$$$ has higher precedence than $$$\star_1$$$ and is evaluated first, so the expression can be read as $$$ a \star_1 (b \star_2 c)$$$.
  • If $$$p_{\star_1} = p_{\star_2}$$$, then the expression will be evaluated from left to right, that is, we use left-associativity, so the expression can be read as $$$(a \star_1 b) \star_2 c$$$.
Parenthesis have the highest precedence, and unary NOT $$$\sim$$$ has the second highest precedence. The precedence of the binary operators is strictly lower than those.

Your task is to build the truth table for a given boolean expression $$$s$$$, but to reduce the size of the output, let's hash it in the following manner:

  • Let $$$m$$$ be the number of distinct variables in $$$s$$$, and let $$$x_0, x_1, \ldots, x_{m-1}$$$ be the variables in increasing order with respect to their index in the alphabet.
  • Let the answer be $$$0$$$.
  • Build a table with $$$2^m$$$ rows numbered from $$$0$$$ to $$$2^m-1$$$.
  • For every row with number $$$r$$$, assign the $$$m$$$ binary digits of $$$r$$$ to the variables: $$$x_{m-1}$$$ gets the least significant digit and so on until $$$x_0$$$ which gets the most significant digit. If $$$s$$$ evaluates to $$$1$$$ for this combination of values, add $$$2^r$$$ to the answer.
  • Since the answer can be very big, only find it modulo $$$10^{18}+3$$$.
Input

The first line contains a string $$$s$$$ ($$$1 \leq |s| \leq 100$$$): an infix valid boolean expression with at most $$$16$$$ distinct variables.

The second line contains six integers, each between 2 and 7: $$$p_\&$$$, $$$p_\wedge$$$, $$$p_|$$$, $$$p_\#$$$, $$$p_\%$$$ and $$$p_\$$$$, the precedence for each binary operator.

Output

Print one integer: the hash of the truth table for the expression $$$s$$$.

Examples
Input
x|y
2 3 4 5 6 7
Output
14
Input
~x|y&z
2 3 4 5 6 7
Output
143
Input
~x|y&z
2 3 2 5 6 7
Output
138
Input
a%b|c^(d&e#f)$g
4 2 5 3 7 6
Output
123140419684712618
Input
~~x
2 3 4 5 6 7
Output
2
Note

The truth tables for the six binary operators are: $$$$$$ \begin{array}{|c|c|c|c|c|} \hline x & y & x \& y & x \wedge y & x | y & x \# y & x \% y & x \$ y \\ \hline 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 \\ \hline 0 & 1 & 0 & 1 & 1 & 1 & 0 & 0 \\ \hline 1 & 0 & 0 & 1 & 1 & 1 & 0 & 0 \\ \hline 1 & 1 & 1 & 0 & 1 & 0 & 1 & 0 \\ \hline \end{array} $$$$$$

In the second example we see that & is evaluated first than |, so the truth table is: $$$$$$ \begin{array}{|c|c|c|} \hline Row & x & y & z & \sim x | y \& z \\ \hline 0 & 0 & 0 & 0 & 1 \\ \hline 1 & 0 & 0 & 1 & 1 \\ \hline 2 & 0 & 1 & 0 & 1 \\ \hline 3 & 0 & 1 & 1 & 1 \\ \hline 4 & 1 & 0 & 0 & 0 \\ \hline 5 & 1 & 0 & 1 & 0 \\ \hline 6 & 1 & 1 & 0 & 0 \\ \hline 7 & 1 & 1 & 1 & 1 \\ \hline \end{array} $$$$$$ The rows that evaluate to $$$1$$$ are $$$0,1,2,3,7$$$, so the answer is $$$2^0+2^1+2^2+2^3+2^7=143$$$.

In the third example both & and | have the same precedence, so we evaluate from left to right (remember that $$$\sim$$$ still has higher precedence): $$$$$$ \begin{array}{|c|c|c|} \hline Row & x & y & z & \sim x | y \& z \\ \hline 0 & 0 & 0 & 0 & 0 \\ \hline 1 & 0 & 0 & 1 & 1 \\ \hline 2 & 0 & 1 & 0 & 0 \\ \hline 3 & 0 & 1 & 1 & 1 \\ \hline 4 & 1 & 0 & 0 & 0 \\ \hline 5 & 1 & 0 & 1 & 0 \\ \hline 6 & 1 & 1 & 0 & 0 \\ \hline 7 & 1 & 1 & 1 & 1 \\ \hline \end{array} $$$$$$ The rows that evaluate to $$$1$$$ are $$$1,3,7$$$, so the answer is $$$2^1+2^3+2^7=138$$$.

I. HuronForces
time limit per test
3 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Pachita is excited for the oncoming ICPC World Finals and is preparing his strategy to train for the competition.

A ladder is a list of $$$N$$$ problems, where the difficulty level of the $$$i$$$-th problem is represented by a positive integer $$$a_i$$$ (the greater $$$a_i$$$ is, the harder the $$$i$$$-th problem is). Initially, only the first problem is available to solve. Once the $$$i$$$-th problem is solved, the $$$(i+1)$$$-th problem becomes available.

With $$$K$$$ days left before the World Finals, Pachita wants to solve all the problems in the ladder of the popular site HuronForces. Every morning, Pachita will access the ladder and see if there is any problem available to solve, and if there any, he will solve it. Once he solves a problem, he can decide to continue solving the next problem or to stop for that day. Pachita has to solve all the problems exactly once before the World Finals and he may solve the last problem before or during the $$$K$$$-th day.

Once Pachita decides to stop solving problems for a certain day, he will look at the difficulty level that he solved the most and his motivation will increase by that level (if there are multiple such difficulty levels, his motivation will increase by the greatest such level). On the other hand, he will look at the difficulty level that he solved the least and his motivation will decrease by that level (if there are multiple such difficulty levels, his motivation will decrease by the lowest such level).

More formally, let's denote the motivation of Pachita by an integer $$$m$$$ (initially $$$m=0$$$). Let's say that the sequence $$$A'=a_i,a_{i+1},...,a_{j-1}, a_j$$$ represents the difficulty levels of the problems solved by Pachita a certain day and $$$f_l$$$ is the frequency of the level $$$l$$$ in $$$A'$$$. Let $$$x$$$ be the greatest difficulty level such that $$$f_x$$$ is the greatest among all $$$f_i$$$ values, and let $$$y$$$ be the lowest difficulty level such that $$$f_y$$$ is the lowest among all $$$f_i$$$ and $$$f_i \gt 0$$$, then $$$m := m + x - y$$$. For example, if Pachita solved problems of level $$$2,4,1,3,2,1$$$ a certain day, then $$$x=2$$$ and $$$y=3$$$ and his motivation will change by $$$x-y=-1$$$.

Help Pachita to find the $$$X$$$ best plans for his training, that is, the $$$X$$$ plans that gives him the best motivation at the end. Two plans are considered different if there exists a problem $$$i$$$ that Pachita solved during the $$$x$$$-th day in the first plan and during the $$$y$$$-th day in the second plan such that $$$x \neq y$$$.

Input

The first line contains three integers $$$N$$$, $$$K$$$ and $$$X$$$ ($$$1 \leq N,K \leq 100$$$ and $$$1 \leq X \leq 10^6$$$) $$$-$$$ number of problems in list, days left before World Finals and the number of plans that Pachita wants to know.

The second line contains $$$N$$$ integers $$$a_1, a_2, ..., a_N$$$ ($$$1 \leq a_i \leq 10^9$$$) $$$-$$$ difficulty level of problems.

Output

Print a single integer with $$$X$$$ integers $$$-$$$ the motivation of the best $$$X$$$ plans in non-increasing order. If there are less than $$$X$$$ possible plans, print $$$.$$$ in the remaining positions.

Examples
Input
6 1 10
2 4 1 3 2 1
Output
-1 . . . . . . . . . 
Input
6 3 10
2 4 1 3 2 1
Output
5 5 5 4 4 4 4 4 4 3 
Input
6 5 10
2 4 1 3 2 1
Output
5 5 5 4 4 4 4 4 4 4 
Note

In the first example, there is one day before the Word Finals and Pachita has to solve all the problems during that day. The explanation of the change in his motivation for that day is written in the problem description.