We have a string S consisting of lowercase English letters.
If the length of S is at most K, print S without change.
If the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.

-----Constraints-----
 - K is an integer between 1 and 100 (inclusive).
 - S is a string consisting of lowercase English letters.
 - The length of S is between 1 and 100 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
K
S

-----Output-----
Print a string as stated in Problem Statement.

-----Sample Input-----
7
nikoandsolstice

-----Sample Output-----
nikoand...

nikoandsolstice has a length of 15, which exceeds K=7.
We should extract the first 7 characters in this string, append ... to the end of them, and print the result nikoand....


In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.
In Taknese, the plural form of a noun is spelled based on the following rules:
 - If a noun's singular form does not end with s, append s to the end of the singular form.
 - If a noun's singular form ends with s, append es to the end of the singular form.
You are given the singular form S of a Taknese noun. Output its plural form.

-----Constraints-----
 - S is a string of length 1 between 1000, inclusive.
 - S contains only lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
Print the plural form of the given Taknese word.

-----Sample Input-----
apple

-----Sample Output-----
apples

apple ends with e, so its plural form is apples.


N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 100
 - 1 \leq K \leq 100
 - 1 \leq d_i \leq N
 - 1 \leq A_{i, 1} < \cdots < A_{i, d_i} \leq N

-----Input-----
Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K}

-----Output-----
Print the answer.

-----Sample Input-----
3 2
2
1 3
1
3

-----Sample Output-----
1

 - Snuke 1 has Snack 1.
 - Snuke 2 has no snacks.
 - Snuke 3 has Snack 1 and 2.
Thus, there will be one victim: Snuke 2.


There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.
Adjacent slimes with the same color will fuse into one larger slime without changing the color. If there were a slime adjacent to this group of slimes before fusion, that slime is now adjacent to the new larger slime.
Ultimately, how many slimes will be there?

-----Constraints-----
 - 1 \leq N \leq 10^5
 - |S| = N
 - S consists of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
N
S

-----Output-----
Print the final number of slimes.

-----Sample Input-----
10
aabbbbaaca

-----Sample Output-----
5

Ultimately, these slimes will fuse into abaca.


As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.

Snuke, an employee, would like to play with this sequence.
Specifically, he would like to repeat the following operation as many times as possible:
For every i satisfying 1 \leq i \leq N, perform one of the following: "divide a_i by 2" and "multiply a_i by 3".
Here, choosing "multiply a_i by 3" for every i is not allowed, and the value of a_i after the operation must be an integer.

At most how many operations can be performed?

-----Constraints-----
 - N is an integer between 1 and 10 \ 000 (inclusive).
 - a_i is an integer between 1 and 1 \ 000 \ 000 \ 000 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 a_3 ... a_N

-----Output-----
Print the maximum number of operations that Snuke can perform.

-----Sample Input-----
3
5 2 4

-----Sample Output-----
3

The sequence is initially {5, 2, 4}. Three operations can be performed as follows:
 - First, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.
 - Next, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.
 - Finally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.


We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.
We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

-----Constraints-----
 - All values in input are integers.
 - 0 \leq A, B, C
 - 1 \leq K \leq A + B + C \leq 2 \times 10^9

-----Input-----
Input is given from Standard Input in the following format:
A B C K

-----Output-----
Print the maximum possible sum of the numbers written on the cards chosen.

-----Sample Input-----
2 1 1 3

-----Sample Output-----
2

Consider picking up two cards with 1s and one card with a 0.
In this case, the sum of the numbers written on the cards is 2, which is the maximum possible value.


There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.
Takahashi says: "there are X animals in total in the garden, and they have Y legs in total." Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.

-----Constraints-----
 - 1 \leq X \leq 100
 - 1 \leq Y \leq 100
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
X Y

-----Output-----
If there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.

-----Sample Input-----
3 8

-----Sample Output-----
Yes

The statement "there are 3 animals in total in the garden, and they have 8 legs in total" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.


You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.

Here, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M).

How many different paths start from vertex 1 and visit all the vertices exactly once?

Here, the endpoints of a path are considered visited.
For example, let us assume that the following undirected graph shown in Figure 1 is given.
Figure 1: an example of an undirected graph
The following path shown in Figure 2 satisfies the condition.
Figure 2: an example of a path that satisfies the condition
However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices.
Figure 3: an example of a path that does not satisfy the condition
Neither the following path shown in Figure 4, because it does not start from vertex 1.
Figure 4: another example of a path that does not satisfy the condition

-----Constraints-----
 - 2≦N≦8
 - 0≦M≦N(N-1)/2
 - 1≦a_i<b_i≦N
 - The given graph contains neither self-loops nor double edges.

-----Input-----
The input is given from Standard Input in the following format:
N M
a_1 b_1
a_2 b_2
:
a_M b_M

-----Output-----
Print the number of the different paths that start from vertex 1 and visit all the vertices exactly once.

-----Sample Input-----
3 3
1 2
1 3
2 3

-----Sample Output-----
2

The given graph is shown in the following figure:
The following two paths satisfy the condition:


You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.
You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.
You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.
You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.
Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.
We can prove that this value is uniquely determined.

-----Constraints-----
 - 2 \leq N \leq 200
 - -100 \leq L \leq 100
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N L

-----Output-----
Find the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.

-----Sample Input-----
5 2

-----Sample Output-----
18

The flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.


Let us define the FizzBuzz sequence a_1,a_2,... as follows:
 - If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}.
 - If the above does not hold but 3 divides i, a_i=\mbox{Fizz}.
 - If none of the above holds but 5 divides i, a_i=\mbox{Buzz}.
 - If none of the above holds, a_i=i.
Find the sum of all numbers among the first N terms of the FizzBuzz sequence.

-----Constraints-----
 - 1 \leq N \leq 10^6

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
Print the sum of all numbers among the first N terms of the FizzBuzz sequence.

-----Sample Input-----
15

-----Sample Output-----
60

The first 15 terms of the FizzBuzz sequence are:
1,2,\mbox{Fizz},4,\mbox{Buzz},\mbox{Fizz},7,8,\mbox{Fizz},\mbox{Buzz},11,\mbox{Fizz},13,14,\mbox{FizzBuzz}
Among them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.


Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.
Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

-----Constraints-----
 - 1 \leq X \leq 100
 - 0 \leq N \leq 100
 - 1 \leq p_i \leq 100
 - p_1, \ldots, p_N are all distinct.
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
X N
p_1 ... p_N

-----Output-----
Print the answer.

-----Sample Input-----
6 5
4 7 10 6 5

-----Sample Output-----
8

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.


There are H rows and W columns of white square cells.
You will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.
How many white cells will remain?
It can be proved that this count does not depend on what rows and columns are chosen.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq H, W \leq 20
 - 1 \leq h \leq H
 - 1 \leq w \leq W

-----Input-----
Input is given from Standard Input in the following format:
H W
h w

-----Output-----
Print the number of white cells that will remain.

-----Sample Input-----
3 2
2 1

-----Sample Output-----
1

There are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.


You are given a sequence of integers of length $n$ and integer number $k$. You should print any integer number $x$ in the range of $[1; 10^9]$ (i.e. $1 \le x \le 10^9$) such that exactly $k$ elements of given sequence are less than or equal to $x$.

Note that the sequence can contain equal elements.

If there is no such $x$, print "-1" (without quotes).

-----Input-----

The first line of the input contains integer numbers $n$ and $k$ ($1 \le n \le 2 \cdot 10^5$, $0 \le k \le n$). The second line of the input contains $n$ integer numbers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) — the sequence itself.

-----Output-----

Print any integer number $x$ from range $[1; 10^9]$ such that exactly $k$ elements of given sequence is less or equal to $x$.

If there is no such $x$, print "-1" (without quotes).

-----Examples-----
Input
7 4
3 7 5 1 10 3 20

Output
6
Input
7 2
3 7 5 1 10 3 20

Output
-1

-----Note-----

In the first example $5$ is also a valid answer because the elements with indices $[1, 3, 4, 6]$ is less than or equal to $5$ and obviously less than or equal to $6$.

In the second example you cannot choose any number that only $2$ elements of the given sequence will be less than or equal to this number because $3$ elements of the given sequence will be also less than or equal to this number.


A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed).

Let's consider empty cells are denoted by '.', then the following figures are stars:

 [Image] The leftmost figure is a star of size $1$, the middle figure is a star of size $2$ and the rightmost figure is a star of size $3$.

You are given a rectangular grid of size $n \times m$ consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from $1$ to $n$, columns are numbered from $1$ to $m$. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed $n \cdot m$. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.

In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most $n \cdot m$ stars.

-----Input-----

The first line of the input contains two integers $n$ and $m$ ($3 \le n, m \le 100$) — the sizes of the given grid.

The next $n$ lines contains $m$ characters each, the $i$-th line describes the $i$-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.

-----Output-----

If it is impossible to draw the given grid using stars only, print "-1".

Otherwise in the first line print one integer $k$ ($0 \le k \le n \cdot m$) — the number of stars needed to draw the given grid. The next $k$ lines should contain three integers each — $x_j$, $y_j$ and $s_j$, where $x_j$ is the row index of the central star character, $y_j$ is the column index of the central star character and $s_j$ is the size of the star. Each star should be completely inside the grid.

-----Examples-----
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........

Output
3
3 4 1
3 5 2
3 5 1

Input
5 5
.*...
****.
.****
..**.
.....

Output
3
2 2 1
3 3 1
3 4 1

Input
5 5
.*...
***..
.*...
.*...
.....

Output
-1

Input
3 3
*.*
.*.
*.*

Output
-1

-----Note-----

In the first example the output 2

3 4 1

3 5 2

is also correct.


Let's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, the third is different from the fourth, and so on). For example, the strings good, string and xyyx are good strings, and the strings bad, aa and aabc are not good. Note that the empty string is considered good.

You are given a string $s$, you have to delete minimum number of characters from this string so that it becomes good.

-----Input-----

The first line contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of characters in $s$.

The second line contains the string $s$, consisting of exactly $n$ lowercase Latin letters.

-----Output-----

In the first line, print one integer $k$ ($0 \le k \le n$) — the minimum number of characters you have to delete from $s$ to make it good.

In the second line, print the resulting string $s$. If it is empty, you may leave the second line blank, or not print it at all.

-----Examples-----
Input
4
good

Output
0
good

Input
4
aabc

Output
2
ab

Input
3
aaa

Output
3


You are given a connected undirected graph consisting of $n$ vertices and $m$ edges. There are no self-loops or multiple edges in the given graph.

You have to direct its edges in such a way that the obtained directed graph does not contain any paths of length two or greater (where the length of path is denoted as the number of traversed edges).

-----Input-----

The first line contains two integer numbers $n$ and $m$ ($2 \le n \le 2 \cdot 10^5$, $n - 1 \le m \le 2 \cdot 10^5$) — the number of vertices and edges, respectively.

The following $m$ lines contain edges: edge $i$ is given as a pair of vertices $u_i$, $v_i$ ($1 \le u_i, v_i \le n$, $u_i \ne v_i$). There are no multiple edges in the given graph, i. e. for each pair ($u_i, v_i$) there are no other pairs ($u_i, v_i$) and ($v_i, u_i$) in the list of edges. It is also guaranteed that the given graph is connected (there is a path between any pair of vertex in the given graph).

-----Output-----

If it is impossible to direct edges of the given graph in such a way that the obtained directed graph does not contain paths of length at least two, print "NO" in the first line.

Otherwise print "YES" in the first line, and then print any suitable orientation of edges: a binary string (the string consisting only of '0' and '1') of length $m$. The $i$-th element of this string should be '0' if the $i$-th edge of the graph should be directed from $u_i$ to $v_i$, and '1' otherwise. Edges are numbered in the order they are given in the input.

-----Example-----
Input
6 5
1 5
2 1
1 4
3 1
6 1

Output
YES
10100

-----Note-----

The picture corresponding to the first example: [Image]

And one of possible answers: $\text{of}$


You are given a set of $n$ segments on the axis $Ox$, each segment has integer endpoints between $1$ and $m$ inclusive. Segments may intersect, overlap or even coincide with each other. Each segment is characterized by two integers $l_i$ and $r_i$ ($1 \le l_i \le r_i \le m$) — coordinates of the left and of the right endpoints.

Consider all integer points between $1$ and $m$ inclusive. Your task is to print all such points that don't belong to any segment. The point $x$ belongs to the segment $[l; r]$ if and only if $l \le x \le r$.

-----Input-----

The first line of the input contains two integers $n$ and $m$ ($1 \le n, m \le 100$) — the number of segments and the upper bound for coordinates.

The next $n$ lines contain two integers each $l_i$ and $r_i$ ($1 \le l_i \le r_i \le m$) — the endpoints of the $i$-th segment. Segments may intersect, overlap or even coincide with each other. Note, it is possible that $l_i=r_i$, i.e. a segment can degenerate to a point.

-----Output-----

In the first line print one integer $k$ — the number of points that don't belong to any segment.

In the second line print exactly $k$ integers in any order — the points that don't belong to any segment. All points you print should be distinct.

If there are no such points at all, print a single integer $0$ in the first line and either leave the second line empty or do not print it at all.

-----Examples-----
Input
3 5
2 2
1 2
5 5

Output
2
3 4

Input
1 7
1 7

Output
0

-----Note-----

In the first example the point $1$ belongs to the second segment, the point $2$ belongs to the first and the second segments and the point $5$ belongs to the third segment. The points $3$ and $4$ do not belong to any segment.

In the second example all the points from $1$ to $7$ belong to the first segment.


You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

-----Constraints-----
 - 1\leq A\leq B\leq 10^{18}
 - 1\leq C,D\leq 10^9
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
A B C D

-----Output-----
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

-----Sample Input-----
4 9 2 3

-----Sample Output-----
2

5 and 7 satisfy the condition.


An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.
Determine whether N is a multiple of 9.

-----Constraints-----
 - 0 \leq N < 10^{200000}
 - N is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
If N is a multiple of 9, print Yes; otherwise, print No.

-----Sample Input-----
123456789

-----Sample Output-----
Yes

The sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.


To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:
 - 1 yen (the currency of Japan)
 - 6 yen, 6^2(=36) yen, 6^3(=216) yen, ...
 - 9 yen, 9^2(=81) yen, 9^3(=729) yen, ...
At least how many operations are required to withdraw exactly N yen in total?
It is not allowed to re-deposit the money you withdrew.

-----Constraints-----
 - 1 \leq N \leq 100000
 - N is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
If at least x operations are required to withdraw exactly N yen in total, print x.

-----Sample Input-----
127

-----Sample Output-----
4

By withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.


You are given string S and T consisting of lowercase English letters.
Determine if S equals T after rotation.
That is, determine if S equals T after the following operation is performed some number of times:
Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.
Here, |X| denotes the length of the string X.

-----Constraints-----
 - 2 \leq |S| \leq 100
 - |S| = |T|
 - S and T consist of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
S
T

-----Output-----
If S equals T after rotation, print Yes; if it does not, print No.

-----Sample Input-----
kyoto
tokyo

-----Sample Output-----
Yes

 - In the first operation, kyoto becomes okyot.
 - In the second operation, okyot becomes tokyo.


Given are two strings S and T.
Let us change some of the characters in S so that T will be a substring of S.
At least how many characters do we need to change?
Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.

-----Constraints-----
 - The lengths of S and T are each at least 1 and at most 1000.
 - The length of T is at most that of S.
 - S and T consist of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
S
T

-----Output-----
Print the minimum number of characters in S that need to be changed.

-----Sample Input-----
cabacc
abc

-----Sample Output-----
1

For example, changing the fourth character a in S to c will match the second through fourth characters in S to T.
Since S itself does not have T as its substring, this number of changes - one - is the minimum needed.


You are given positive integers A and B.
Find the K-th largest positive integer that divides both A and B.
The input guarantees that there exists such a number.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq A, B \leq 100
 - The K-th largest positive integer that divides both A and B exists.
 - K \geq 1

-----Input-----
Input is given from Standard Input in the following format:
A B K

-----Output-----
Print the K-th largest positive integer that divides both A and B.

-----Sample Input-----
8 12 2

-----Sample Output-----
2

Three positive integers divides both 8 and 12: 1, 2 and 4.
Among them, the second largest is 2.


Takahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)
Takahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?
(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)

-----Constraints-----
 - 0 \leq X \leq 10^9
 - X is an integer.

-----Input-----
Input is given from Standard Input in the following format:
X

-----Output-----
Print the maximum number of happiness points that can be earned.

-----Sample Input-----
1024

-----Sample Output-----
2020

By exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.


There are N people living on a number line.
The i-th person lives at coordinate X_i.
You are going to hold a meeting that all N people have to attend.
The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.
Find the minimum total points of stamina the N people have to spend.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 100
 - 1 \leq X_i \leq 100

-----Input-----
Input is given from Standard Input in the following format:
N
X_1 X_2 ... X_N

-----Output-----
Print the minimum total stamina the N people have to spend.

-----Sample Input-----
2
1 4

-----Sample Output-----
5

Assume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.
Note that you can hold the meeting only at an integer coordinate.


Takahashi's house has only one socket.
Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.
One power strip with A sockets can extend one empty socket into A empty sockets.
Find the minimum number of power strips required.

-----Constraints-----
 - All values in input are integers.
 - 2 \leq A \leq 20
 - 1 \leq B \leq 20

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
Print the minimum number of power strips required.

-----Sample Input-----
4 10

-----Sample Output-----
3

3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.


You will be given a string S of length 3 representing the weather forecast for three days in the past.
The i-th character (1 \leq i \leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.
You will also be given a string T of length 3 representing the actual weather on those three days.
The i-th character (1 \leq i \leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.
Print the number of days for which the forecast was correct.

-----Constraints-----
 - S and T are strings of length 3 each.
 - S and T consist of S, C, and R.

-----Input-----
Input is given from Standard Input in the following format:
S
T

-----Output-----
Print the number of days for which the forecast was correct.

-----Sample Input-----
CSS
CSR

-----Sample Output-----
2

 - For the first day, it was forecast to be cloudy, and it was indeed cloudy.
 - For the second day, it was forecast to be sunny, and it was indeed sunny.
 - For the third day, it was forecast to be sunny, but it was rainy.
Thus, the forecast was correct for two days in this case.


We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following condition:
 - p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

-----Constraints-----
 - All values in input are integers.
 - 3 \leq n \leq 20
 - p is a permutation of {1,\ 2,\ ...,\ n}.

-----Input-----
Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n

-----Output-----
Print the number of elements p_i (1 < i < n) that satisfy the condition.

-----Sample Input-----
5
1 3 5 4 2

-----Sample Output-----
2

p_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane.

Each of the next n lines contains two real coordinates x_{i} and y_{i} of the $i^{\text{th}}$ point, specified with exactly 2 fractional digits. All coordinates are between  - 1000 and 1000, inclusive.

-----Output-----

Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10^{ - 2}.

-----Examples-----
Input
8
-2.14 2.06
-1.14 2.04
-2.16 1.46
-2.14 0.70
-1.42 0.40
-0.94 -0.48
-1.42 -1.28
-2.16 -1.62

Output
5.410

Input
5
2.26 1.44
2.28 0.64
2.30 -0.30
1.58 0.66
3.24 0.66

Output
5.620

Input
8
6.98 2.06
6.40 1.12
5.98 0.24
5.54 -0.60
7.16 0.30
7.82 1.24
8.34 0.24
8.74 -0.76

Output
5.480

Input
5
10.44 2.06
10.90 0.80
11.48 -0.48
12.06 0.76
12.54 2.06

Output
6.040

Input
8
16.94 2.42
15.72 2.38
14.82 1.58
14.88 0.50
15.76 -0.16
16.86 -0.20
17.00 0.88
16.40 0.92

Output
6.040

Input
7
20.62 3.00
21.06 2.28
21.56 1.36
21.66 0.56
21.64 -0.52
22.14 2.32
22.62 3.04

Output
6.720


The only difference between easy and hard versions is the constraints.

Polycarp has to write a coursework. The coursework consists of $m$ pages.

Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He can drink cups in any order. Polycarp drinks each cup instantly and completely (i.e. he cannot split any cup into several days).

Surely, courseworks are not being written in a single day (in a perfect world of Berland, at least).

Let's consider some day of Polycarp's work. Consider Polycarp drinks $k$ cups of coffee during this day and caffeine dosages of cups Polycarp drink during this day are $a_{i_1}, a_{i_2}, \dots, a_{i_k}$. Then the first cup he drinks gives him energy to write $a_{i_1}$ pages of coursework, the second cup gives him energy to write $max(0, a_{i_2} - 1)$ pages, the third cup gives him energy to write $max(0, a_{i_3} - 2)$ pages, ..., the $k$-th cup gives him energy to write $max(0, a_{i_k} - k + 1)$ pages.

If Polycarp doesn't drink coffee during some day, he cannot write coursework at all that day.

Polycarp has to finish his coursework as soon as possible (spend the minimum number of days to do it). Your task is to find out this number of days or say that it is impossible.

-----Input-----

The first line of the input contains two integers $n$ and $m$ ($1 \le n \le 2 \cdot 10^5$, $1 \le m \le 10^9$) — the number of cups of coffee and the number of pages in the coursework.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is the caffeine dosage of coffee in the $i$-th cup.

-----Output-----

If it is impossible to write the coursework, print -1. Otherwise print the minimum number of days Polycarp needs to do it.

-----Examples-----
Input
5 8
2 3 1 1 2

Output
4

Input
7 10
1 3 4 2 1 4 2

Output
2

Input
5 15
5 5 5 5 5

Output
1

Input
5 16
5 5 5 5 5

Output
2

Input
5 26
5 5 5 5 5

Output
-1

-----Note-----

In the first example Polycarp can drink fourth cup during first day (and write $1$ page), first and second cups during second day (and write $2 + (3 - 1) = 4$ pages), fifth cup during the third day (and write $2$ pages) and third cup during the fourth day (and write $1$ page) so the answer is $4$. It is obvious that there is no way to write the coursework in three or less days.

In the second example Polycarp can drink third, fourth and second cups during first day (and write $4 + (2 - 1) + (3 - 2) = 6$ pages) and sixth cup during second day (and write $4$ pages) so the answer is $2$. It is obvious that Polycarp cannot write the whole coursework in one day in this test.

In the third example Polycarp can drink all cups of coffee during first day and write $5 + (5 - 1) + (5 - 2) + (5 - 3) + (5 - 4) = 15$ pages of coursework.

In the fourth example Polycarp cannot drink all cups during first day and should drink one of them during the second day. So during first day he will write $5 + (5 - 1) + (5 - 2) + (5 - 3) = 14$ pages of coursework and during second day he will write $5$ pages of coursework. This is enough to complete it.

In the fifth example Polycarp cannot write the whole coursework at all, even if he will drink one cup of coffee during each day, so the answer is -1.


You are given an array $s$ consisting of $n$ integers.

You have to find any array $t$ of length $k$ such that you can cut out maximum number of copies of array $t$ from array $s$.

Cutting out the copy of $t$ means that for each element $t_i$ of array $t$ you have to find $t_i$ in $s$ and remove it from $s$. If for some $t_i$ you cannot find such element in $s$, then you cannot cut out one more copy of $t$. The both arrays can contain duplicate elements.

For example, if $s = [1, 2, 3, 2, 4, 3, 1]$ and $k = 3$ then one of the possible answers is $t = [1, 2, 3]$. This array $t$ can be cut out $2$ times.   To cut out the first copy of $t$ you can use the elements $[1, \underline{\textbf{2}}, 3, 2, 4, \underline{\textbf{3}}, \underline{\textbf{1}}]$ (use the highlighted elements). After cutting out the first copy of $t$ the array $s$ can look like $[1, 3, 2, 4]$.  To cut out the second copy of $t$ you can use the elements $[\underline{\textbf{1}}, \underline{\textbf{3}}, \underline{\textbf{2}}, 4]$. After cutting out the second copy of $t$ the array $s$ will be $[4]$.

Your task is to find such array $t$ that you can cut out the copy of $t$ from $s$ maximum number of times. If there are multiple answers, you may choose any of them.

-----Input-----

The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in $s$ and the desired number of elements in $t$, respectively.

The second line of the input contains exactly $n$ integers $s_1, s_2, \dots, s_n$ ($1 \le s_i \le 2 \cdot 10^5$).

-----Output-----

Print $k$ integers — the elements of array $t$ such that you can cut out maximum possible number of copies of this array from $s$. If there are multiple answers, print any of them. The required array $t$ can contain duplicate elements. All the elements of $t$ ($t_1, t_2, \dots, t_k$) should satisfy the following condition: $1 \le t_i \le 2 \cdot 10^5$.

-----Examples-----
Input
7 3
1 2 3 2 4 3 1

Output
1 2 3

Input
10 4
1 3 1 3 10 3 7 7 12 3

Output
7 3 1 3

Input
15 2
1 2 1 1 1 2 1 1 2 1 2 1 1 1 1

Output
1 1

-----Note-----

The first example is described in the problem statement.

In the second example the only answer is $[7, 3, 1, 3]$ and any its permutations. It can be shown that you cannot choose any other array such that the maximum number of copies you can cut out would be equal to $2$.

In the third example the array $t$ can be cut out $5$ times.


You are given a matrix $a$, consisting of $n$ rows and $m$ columns. Each cell contains an integer in it.

You can change the order of rows arbitrarily (including leaving the initial order), but you can't change the order of cells in a row. After you pick some order of rows, you traverse the whole matrix the following way: firstly visit all cells of the first column from the top row to the bottom one, then the same for the second column and so on. During the traversal you write down the sequence of the numbers on the cells in the same order you visited them. Let that sequence be $s_1, s_2, \dots, s_{nm}$.

The traversal is $k$-acceptable if for all $i$ ($1 \le i \le nm - 1$) $|s_i - s_{i + 1}| \ge k$.

Find the maximum integer $k$ such that there exists some order of rows of matrix $a$ that it produces a $k$-acceptable traversal.

-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n \le 16$, $1 \le m \le 10^4$, $2 \le nm$) — the number of rows and the number of columns, respectively.

Each of the next $n$ lines contains $m$ integers ($1 \le a_{i, j} \le 10^9$) — the description of the matrix.

-----Output-----

Print a single integer $k$ — the maximum number such that there exists some order of rows of matrix $a$ that it produces an $k$-acceptable traversal.

-----Examples-----
Input
4 2
9 9
10 8
5 3
4 3

Output
5

Input
2 4
1 2 3 4
10 3 7 3

Output
0

Input
6 1
3
6
2
5
1
4

Output
3

-----Note-----

In the first example you can rearrange rows as following to get the $5$-acceptable traversal:

5 3

10 8

4 3

9 9

Then the sequence $s$ will be $[5, 10, 4, 9, 3, 8, 3, 9]$. Each pair of neighbouring elements have at least $k = 5$ difference between them.

In the second example the maximum $k = 0$, any order is $0$-acceptable.

In the third example the given order is already $3$-acceptable, you can leave it as it is.


You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the social network topic. In this case, the file is not sent and an error message is displayed.

Determine the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. Print 0 if the file name does not initially contain a forbidden substring "xxx".

You can delete characters in arbitrary positions (not necessarily consecutive). If you delete a character, then the length of a string is reduced by $1$. For example, if you delete the character in the position $2$ from the string "exxxii", then the resulting string is "exxii".

-----Input-----

The first line contains integer $n$ $(3 \le n \le 100)$ — the length of the file name.

The second line contains a string of length $n$ consisting of lowercase Latin letters only — the file name.

-----Output-----

Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0.

-----Examples-----
Input
6
xxxiii

Output
1

Input
5
xxoxx

Output
0

Input
10
xxxxxxxxxx

Output
8

-----Note-----

In the first example Polycarp tried to send a file with name contains number $33$, written in Roman numerals. But he can not just send the file, because it name contains three letters "x" in a row. To send the file he needs to remove any one of this letters.


It is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.
Given an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.

-----Constraints-----
 - 1 \leq r \leq 100
 - r is an integer.

-----Input-----
Input is given from Standard Input in the following format:
r

-----Output-----
Print an integer representing the area of the regular dodecagon.

-----Sample Input-----
4

-----Sample Output-----
48

The area of the regular dodecagon is 3 \times 4^2 = 48.


There are S sheep and W wolves.
If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.
If the wolves will attack the sheep, print unsafe; otherwise, print safe.

-----Constraints-----
 - 1 \leq S \leq 100
 - 1 \leq W \leq 100

-----Input-----
Input is given from Standard Input in the following format:
S W

-----Output-----
If the wolves will attack the sheep, print unsafe; otherwise, print safe.

-----Sample Input-----
4 5

-----Sample Output-----
unsafe

There are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.


There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.

-----Constraints-----
 - 1 \leq |AB|,|BC|,|CA| \leq 100
 - All values in input are integers.
 - The area of the triangle ABC is an integer.

-----Input-----
Input is given from Standard Input in the following format:
|AB| |BC| |CA|

-----Output-----
Print the area of the triangle ABC.

-----Sample Input-----
3 4 5

-----Sample Output-----
6

This triangle has an area of 6.


Takahashi likes the sound when he buys a drink from a vending machine.
That sound can be heard by spending A yen (the currency of Japan) each time.
Takahashi has B yen. He will hear the sound as many times as he can with that money, but at most C times, as he would be satisfied at that time.
How many times will he hear the sound?

-----Constraints-----
 - All values in input are integers.
 - 1 \leq A, B, C \leq 100

-----Input-----
Input is given from Standard Input in the following format:
A B C

-----Output-----
Print the number of times Takahashi will hear his favorite sound.

-----Sample Input-----
2 11 4

-----Sample Output-----
4

Since he has not less than 8 yen, he will hear the sound four times and be satisfied.


Compute A \times B.

-----Constraints-----
 - 1 \leq A \leq 100
 - 1 \leq B \leq 100
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
Print the value A \times B as an integer.

-----Sample Input-----
2 5

-----Sample Output-----
10

We have 2 \times 5 = 10.


A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.
Find the total number of biscuits produced within T + 0.5 seconds after activation.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq A, B, T \leq 20

-----Input-----
Input is given from Standard Input in the following format:
A B T

-----Output-----
Print the total number of biscuits produced within T + 0.5 seconds after activation.

-----Sample Input-----
3 5 7

-----Sample Output-----
10

 - Five biscuits will be produced three seconds after activation.
 - Another five biscuits will be produced six seconds after activation.
 - Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.


Takahashi the Jumbo will practice golf.
His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).
If he can achieve the objective, print OK; if he cannot, print NG.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq A \leq B \leq 1000
 - 1 \leq K \leq 1000

-----Input-----
Input is given from Standard Input in the following format:
K
A B

-----Output-----
If he can achieve the objective, print OK; if he cannot, print NG.

-----Sample Input-----
7
500 600

-----Sample Output-----
OK

Among the multiples of 7, for example, 567 lies between 500 and 600.


In order to pass the entrance examination tomorrow, Taro has to study for T more hours.
Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T hours in World B?

-----Constraints-----
 - All values in input are integers.
 - 1 \leq T \leq 100
 - 1 \leq X \leq 100

-----Input-----
Input is given from Standard Input in the following format:
T X

-----Output-----
Print the number of hours that will pass in World A.
The output will be regarded as correct when its absolute or relative error from the judge's output is at most 10^{-3}.

-----Sample Input-----
8 3

-----Sample Output-----
2.6666666667

While Taro studies for eight hours in World B where time passes three times as fast, 2.6666... hours will pass in World A.
Note that an absolute or relative error of at most 10^{-3} is allowed.


We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2?

-----Constraints-----
 - All values in input are integers.
 - 1 \leq B \leq A \leq 20
 - 1 \leq C \leq 20

-----Input-----
Input is given from Standard Input in the following format:
A B C

-----Output-----
Print the integer representing the amount of water, in milliliters, that will remain in Bottle 2.

-----Sample Input-----
6 4 3

-----Sample Output-----
1

We will transfer two milliliters of water from Bottle 2 to Bottle 1, and one milliliter of water will remain in Bottle 2.


We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).
There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

-----Notes-----
For two sequences X and Y, X is said to be lexicographically smaller than Y if and only if there exists an integer k such that X_i = Y_i~(1 \leq i < k) and X_k < Y_k.

-----Constraints-----
 - 2 \leq N \leq 8
 - P and Q are permutations of size N.

-----Input-----
Input is given from Standard Input in the following format:
N
P_1 P_2 ... P_N
Q_1 Q_2 ... Q_N

-----Output-----
Print |a - b|.

-----Sample Input-----
3
1 3 2
3 1 2

-----Sample Output-----
3

There are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3), (2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come 2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.


You are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than A, C, G and T.

-----Notes-----
A substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.
For example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and  (the empty string), but not AC.

-----Constraints-----
 - S is a string of length between 1 and 10 (inclusive).
 - Each character in S is an uppercase English letter.

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
Print the length of the longest ACGT string that is a substring of S.

-----Sample Input-----
ATCODER

-----Sample Output-----
3

Among the ACGT strings that are substrings of ATCODER, the longest one is ATC.


Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).

-----Constraints-----
 - 1 \leq N \leq 10^5

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
Print the number of positive integers less than or equal to N that have an odd number of digits.

-----Sample Input-----
11

-----Sample Output-----
9

Among the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \ldots, 9.


Given are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.
Operation: Choose one character of S and replace it with a different character.

-----Constraints-----
 - S and T have lengths between 1 and 2\times 10^5 (inclusive).
 - S and T consists of lowercase English letters.
 - S and T have equal lengths.

-----Input-----
Input is given from Standard Input in the following format:
S
T

-----Output-----
Print the answer.

-----Sample Input-----
cupofcoffee
cupofhottea

-----Sample Output-----
4

We can achieve the objective in four operations, such as the following:
 - First, replace the sixth character c with h.
 - Second, replace the eighth character f with t.
 - Third, replace the ninth character f with t.
 - Fourth, replace the eleventh character e with a.


There are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \ldots, 999999, 1000000.
Among them, some K consecutive stones are painted black, and the others are painted white.
Additionally, we know that the stone at coordinate X is painted black.
Print all coordinates that potentially contain a stone painted black, in ascending order.

-----Constraints-----
 - 1 \leq K \leq 100
 - 0 \leq X \leq 100
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
K X

-----Output-----
Print all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.

-----Sample Input-----
3 7

-----Sample Output-----
5 6 7 8 9

We know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:
 - The three stones painted black are placed at coordinates 5, 6, and 7.
 - The three stones painted black are placed at coordinates 6, 7, and 8.
 - The three stones painted black are placed at coordinates 7, 8, and 9.
Thus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.


You will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.
The current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?

-----Constraints-----
 - -40 \leq X \leq 40
 - X is an integer.

-----Input-----
Input is given from Standard Input in the following format:
X

-----Output-----
Print Yes if you will turn on the air conditioner; print No otherwise.

-----Sample Input-----
25

-----Sample Output-----
No


There are N points in a D-dimensional space.
The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).
The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.
How many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?

-----Constraints-----
 - All values in input are integers.
 - 2 \leq N \leq 10
 - 1 \leq D \leq 10
 - -20 \leq X_{ij} \leq 20
 - No two given points have the same coordinates. That is, if i \neq j, there exists k such that X_{ik} \neq X_{jk}.

-----Input-----
Input is given from Standard Input in the following format:
N D
X_{11} X_{12} ... X_{1D}
X_{21} X_{22} ... X_{2D}
\vdots
X_{N1} X_{N2} ... X_{ND}

-----Output-----
Print the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.

-----Sample Input-----
3 2
1 2
5 5
-2 8

-----Sample Output-----
1

The number of pairs with an integer distance is one, as follows:
 - The distance between the first point and the second point is \sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.
 - The distance between the second point and the third point is \sqrt{|5-(-2)|^2 + |5-8|^2} = \sqrt{58}, which is not an integer.
 - The distance between the third point and the first point is \sqrt{|-2-1|^2+|8-2|^2} = 3\sqrt{5}, which is not an integer.


The door of Snuke's laboratory is locked with a security code.
The security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.
You are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.

-----Constraints-----
 - S is a 4-character string consisting of digits.

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
If S is hard to enter, print Bad; otherwise, print Good.

-----Sample Input-----
3776

-----Sample Output-----
Bad

The second and third digits are the same, so 3776 is hard to enter.


You have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \leq i \leq N) is v_i.
When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.
After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.

-----Constraints-----
 - 2 \leq N \leq 50
 - 1 \leq v_i \leq 1000
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
v_1 v_2 \ldots v_N

-----Output-----
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.
Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.

-----Sample Input-----
2
3 4

-----Sample Output-----
3.5

If you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.
Printing 3.50001, 3.49999, and so on will also be accepted.


Takahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \ldots, Dish N) once.
The i-th dish (1 \leq i \leq N) he ate was Dish A_i.
When he eats Dish i (1 \leq i \leq N), he gains B_i satisfaction points.
Additionally, when he eats Dish i+1 just after eating Dish i (1 \leq i \leq N - 1), he gains C_i more satisfaction points.
Find the sum of the satisfaction points he gained.

-----Constraints-----
 - All values in input are integers.
 - 2 \leq N \leq 20
 - 1 \leq A_i \leq N
 - A_1, A_2, ..., A_N are all different.
 - 1 \leq B_i \leq 50
 - 1 \leq C_i \leq 50

-----Input-----
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
B_1 B_2 ... B_N
C_1 C_2 ... C_{N-1}

-----Output-----
Print the sum of the satisfaction points Takahashi gained, as an integer.

-----Sample Input-----
3
3 1 2
2 5 4
3 6

-----Sample Output-----
14

Takahashi gained 14 satisfaction points in total, as follows:
 - First, he ate Dish 3 and gained 4 satisfaction points.
 - Next, he ate Dish 1 and gained 2 satisfaction points.
 - Lastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.


We have a string S of length N consisting of uppercase English letters.
How many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?

-----Constraints-----
 - 3 \leq N \leq 50
 - S consists of uppercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
N
S

-----Output-----
Print number of occurrences of ABC in S as contiguous subsequences.

-----Sample Input-----
10
ZABCDBABCQ

-----Sample Output-----
2

Two contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.


There are N people. The name of the i-th person is S_i.
We would like to choose three people so that the following conditions are met:
 - The name of every chosen person begins with M, A, R, C or H.
 - There are no multiple people whose names begin with the same letter.
How many such ways are there to choose three people, disregarding order?
Note that the answer may not fit into a 32-bit integer type.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - S_i consists of uppercase English letters.
 - 1 \leq |S_i| \leq 10
 - S_i \neq S_j (i \neq j)

-----Input-----
Input is given from Standard Input in the following format:
N
S_1
:
S_N

-----Output-----
If there are x ways to choose three people so that the given conditions are met, print x.

-----Sample Input-----
5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI

-----Sample Output-----
2

We can choose three people with the following names:
 - MASHIKE, RUMOI, HABORO
 - MASHIKE, RUMOI, HOROKANAI
Thus, we have two ways.


Takahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.

The problem has N test cases, all of which must be passed to get an AC verdict.

Takahashi's submission has passed M cases out of the N test cases.

Determine whether Takahashi's submission gets an AC.

-----Constraints-----
 - 1 \leq N \leq 100
 - 0 \leq M \leq N
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N M

-----Output-----
If Takahashi's submission gets an AC, print Yes; otherwise, print No.

-----Sample Input-----
3 3

-----Sample Output-----
Yes

All three test cases have been passed, so his submission gets an AC.


A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.

Given a string S, determine whether it is coffee-like.

-----Constraints-----
 - S is a string of length 6 consisting of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
If S is coffee-like, print Yes; otherwise, print No.

-----Sample Input-----
sippuu

-----Sample Output-----
Yes

In sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.


When Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.
You, the smartwatch, has found N routes to his home.
If Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.
Find the smallest cost of a route that takes not longer than time T.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 100
 - 1 \leq T \leq 1000
 - 1 \leq c_i \leq 1000
 - 1 \leq t_i \leq 1000
 - The pairs (c_i, t_i) are distinct.

-----Input-----
Input is given from Standard Input in the following format:
N T
c_1 t_1
c_2 t_2
:
c_N t_N

-----Output-----
Print the smallest cost of a route that takes not longer than time T.
If there is no route that takes not longer than time T, print TLE instead.

-----Sample Input-----
3 70
7 60
1 80
4 50

-----Sample Output-----
4

 - The first route gets him home at cost 7.
 - The second route takes longer than time T = 70.
 - The third route gets him home at cost 4.
Thus, the cost 4 of the third route is the minimum.


N of us are going on a trip, by train or taxi.
The train will cost each of us A yen (the currency of Japan).
The taxi will cost us a total of B yen.
How much is our minimum total travel expense?

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 20
 - 1 \leq A \leq 50
 - 1 \leq B \leq 50

-----Input-----
Input is given from Standard Input in the following format:
N A B

-----Output-----
Print an integer representing the minimum total travel expense.

-----Sample Input-----
4 2 9

-----Sample Output-----
8

The train will cost us 4 \times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.


We will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.
For example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.
Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

-----Constraints-----
 - 2 \leq N \leq 10^5
 - s_i is a string of length 10.
 - Each character in s_i is a lowercase English letter.
 - s_1, s_2, \ldots, s_N are all distinct.

-----Input-----
Input is given from Standard Input in the following format:
N
s_1
s_2
:
s_N

-----Output-----
Print the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

-----Sample Input-----
3
acornistnt
peanutbomb
constraint

-----Sample Output-----
1

s_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.


The only difference between the easy and the hard versions is the maximum value of $k$.

You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — from $1$ to $2$, the third one — from $1$ to $3$, $\dots$, the $i$-th block consists of all numbers from $1$ to $i$.

So the first $56$ elements of the sequence are "11212312341234512345612345671234567812345678912345678910". Elements of the sequence are numbered from one. For example, the $1$-st element of the sequence is $1$, the $3$-rd element of the sequence is $2$, the $20$-th element of the sequence is $5$, the $38$-th element is $2$, the $56$-th element of the sequence is $0$.

Your task is to answer $q$ independent queries. In the $i$-th query you are given one integer $k_i$. Calculate the digit at the position $k_i$ of the sequence.

-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 500$) — the number of queries.

The $i$-th of the following $q$ lines contains one integer $k_i$ $(1 \le k_i \le 10^9)$ — the description of the corresponding query.

-----Output-----

Print $q$ lines. In the $i$-th line print one digit $x_i$ $(0 \le x_i \le 9)$ — the answer to the query $i$, i.e. $x_i$ should be equal to the element at the position $k_i$ of the sequence.

-----Examples-----
Input
5
1
3
20
38
56

Output
1
2
5
2
0

Input
4
2132
506
999999999
1000000000

Output
8
2
9
8

-----Note-----

Answers on queries from the first example are described in the problem statement.


Treeland consists of $n$ cities and $n-1$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right — the country's topology is an undirected tree.

There are some private road companies in Treeland. The government decided to sell roads to the companies. Each road will belong to one company and a company can own multiple roads.

The government is afraid to look unfair. They think that people in a city can consider them unfair if there is one company which owns two or more roads entering the city. The government wants to make such privatization that the number of such cities doesn't exceed $k$ and the number of companies taking part in the privatization is minimal.

Choose the number of companies $r$ such that it is possible to assign each road to one company in such a way that the number of cities that have two or more roads of one company is at most $k$. In other words, if for a city all the roads belong to the different companies then the city is good. Your task is to find the minimal $r$ that there is such assignment to companies from $1$ to $r$ that the number of cities which are not good doesn't exceed $k$. [Image] The picture illustrates the first example ($n=6, k=2$). The answer contains $r=2$ companies. Numbers on the edges denote edge indices. Edge colors mean companies: red corresponds to the first company, blue corresponds to the second company. The gray vertex (number $3$) is not good. The number of such vertices (just one) doesn't exceed $k=2$. It is impossible to have at most $k=2$ not good cities in case of one company.

-----Input-----

The first line contains two integers $n$ and $k$ ($2 \le n \le 200000, 0 \le k \le n - 1$) — the number of cities and the maximal number of cities which can have two or more roads belonging to one company.

The following $n-1$ lines contain roads, one road per line. Each line contains a pair of integers $x_i$, $y_i$ ($1 \le x_i, y_i \le n$), where $x_i$, $y_i$ are cities connected with the $i$-th road.

-----Output-----

In the first line print the required $r$ ($1 \le r \le n - 1$). In the second line print $n-1$ numbers $c_1, c_2, \dots, c_{n-1}$ ($1 \le c_i \le r$), where $c_i$ is the company to own the $i$-th road. If there are multiple answers, print any of them.

-----Examples-----
Input
6 2
1 4
4 3
3 5
3 6
5 2

Output
2
1 2 1 1 2
Input
4 2
3 1
1 4
1 2

Output
1
1 1 1
Input
10 2
10 3
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9

Output
3
1 1 2 3 2 3 1 3 1


Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...

$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.

For all friends $1 \le x_i \le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).

For example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.

So all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?

-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of friends.

The second line contains $n$ integers $x_1, x_2, \dots, x_n$ ($1 \le x_i \le n$) — the coordinates of the houses of the friends.

-----Output-----

Print two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.

-----Examples-----
Input
4
1 2 4 4

Output
2 4

Input
9
1 1 8 8 8 4 4 4 4

Output
3 8

Input
7
4 3 7 1 4 3 3

Output
3 6

-----Note-----

In the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.

For the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.


There are $n$ kids, numbered from $1$ to $n$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $p_1$, $p_2$, ..., $p_n$ (all these numbers are from $1$ to $n$ and are distinct, so $p$ is a permutation). Let the next kid for a kid $p_i$ be kid $p_{i + 1}$ if $i < n$ and $p_1$ otherwise. After the dance, each kid remembered two kids: the next kid (let's call him $x$) and the next kid for $x$. Each kid told you which kids he/she remembered: the kid $i$ remembered kids $a_{i, 1}$ and $a_{i, 2}$. However, the order of $a_{i, 1}$ and $a_{i, 2}$ can differ from their order in the circle. [Image] Example: 5 kids in a circle, $p=[3, 2, 4, 1, 5]$ (or any cyclic shift). The information kids remembered is: $a_{1,1}=3$, $a_{1,2}=5$; $a_{2,1}=1$, $a_{2,2}=4$; $a_{3,1}=2$, $a_{3,2}=4$; $a_{4,1}=1$, $a_{4,2}=5$; $a_{5,1}=2$, $a_{5,2}=3$.

You have to restore the order of the kids in the circle using this information. If there are several answers, you may print any. It is guaranteed that at least one solution exists.

If you are Python programmer, consider using PyPy instead of Python when you submit your code.

-----Input-----

The first line of the input contains one integer $n$ ($3 \le n \le 2 \cdot 10^5$) — the number of the kids.

The next $n$ lines contain $2$ integers each. The $i$-th line contains two integers $a_{i, 1}$ and $a_{i, 2}$ ($1 \le a_{i, 1}, a_{i, 2} \le n, a_{i, 1} \ne a_{i, 2}$) — the kids the $i$-th kid remembered, given in arbitrary order.

-----Output-----

Print $n$ integers $p_1$, $p_2$, ..., $p_n$ — permutation of integers from $1$ to $n$, which corresponds to the order of kids in the circle. If there are several answers, you may print any (for example, it doesn't matter which kid is the first in the circle). It is guaranteed that at least one solution exists.

-----Examples-----
Input
5
3 5
1 4
2 4
1 5
2 3

Output
3 2 4 1 5

Input
3
2 3
3 1
1 2

Output
3 1 2


You are a coach at your local university. There are $n$ students under your supervision, the programming skill of the $i$-th student is $a_i$.

You have to create a team for a new programming competition. As you know, the more students some team has the more probable its victory is! So you have to create a team with the maximum number of students. But you also know that a team should be balanced. It means that the programming skill of each pair of students in a created team should differ by no more than $5$.

Your task is to report the maximum possible number of students in a balanced team.

-----Input-----

The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of students.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is a programming skill of the $i$-th student.

-----Output-----

Print one integer — the maximum possible number of students in a balanced team.

-----Examples-----
Input
6
1 10 17 12 15 2

Output
3

Input
10
1337 1337 1337 1337 1337 1337 1337 1337 1337 1337

Output
10

Input
6
1 1000 10000 10 100 1000000000

Output
1

-----Note-----

In the first example you can create a team with skills $[12, 17, 15]$.

In the second example you can take all students in a team because their programming skills are equal.

In the third example you can create a team consisting of a single student (and you cannot create a team consisting of at least two students).


Vova is playing a computer game. There are in total $n$ turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is $k$.

During each turn Vova can choose what to do:   If the current charge of his laptop battery is strictly greater than $a$, Vova can just play, and then the charge of his laptop battery will decrease by $a$;  if the current charge of his laptop battery is strictly greater than $b$ ($b<a$), Vova can play and charge his laptop, and then the charge of his laptop battery will decrease by $b$;  if the current charge of his laptop battery is less than or equal to $a$ and $b$ at the same time then Vova cannot do anything and loses the game.

Regardless of Vova's turns the charge of the laptop battery is always decreases.

Vova wants to complete the game (Vova can complete the game if after each of $n$ turns the charge of the laptop battery is strictly greater than $0$). Vova has to play exactly $n$ turns. Among all possible ways to complete the game, Vova wants to choose the one where the number of turns when he just plays (first type turn) is the maximum possible. It is possible that Vova cannot complete the game at all.

Your task is to find out the maximum possible number of turns Vova can just play (make the first type turn) or report that Vova cannot complete the game.

You have to answer $q$ independent queries.

-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 10^5$) — the number of queries. Each query is presented by a single line.

The only line of the query contains four integers $k, n, a$ and $b$ ($1 \le k, n \le 10^9, 1 \le b < a \le 10^9$) — the initial charge of Vova's laptop battery, the number of turns in the game and values $a$ and $b$, correspondingly.

-----Output-----

For each query print one integer: -1 if Vova cannot complete the game or the maximum number of turns Vova can just play (make the first type turn) otherwise.

-----Example-----
Input
6
15 5 3 2
15 5 4 3
15 5 2 1
15 5 5 1
16 7 5 2
20 5 7 3

Output
4
-1
5
2
0
1

-----Note-----

In the first example query Vova can just play $4$ turns and spend $12$ units of charge and then one turn play and charge and spend $2$ more units. So the remaining charge of the battery will be $1$.

In the second example query Vova cannot complete the game because even if he will play and charge the battery during each turn then the charge of the laptop battery will be $0$ after the last turn.


You are given a string $s$ consisting of lowercase Latin letters "a", "b" and "c" and question marks "?".

Let the number of question marks in the string $s$ be $k$. Let's replace each question mark with one of the letters "a", "b" and "c". Here we can obtain all $3^{k}$ possible strings consisting only of letters "a", "b" and "c". For example, if $s = $"ac?b?c" then we can obtain the following strings: $[$"acabac", "acabbc", "acabcc", "acbbac", "acbbbc", "acbbcc", "accbac", "accbbc", "accbcc"$]$.

Your task is to count the total number of subsequences "abc" in all resulting strings. Since the answer can be very large, print it modulo $10^{9} + 7$.

A subsequence of the string $t$ is such a sequence that can be derived from the string $t$ after removing some (possibly, zero) number of letters without changing the order of remaining letters. For example, the string "baacbc" contains two subsequences "abc" — a subsequence consisting of letters at positions $(2, 5, 6)$ and a subsequence consisting of letters at positions $(3, 5, 6)$.

-----Input-----

The first line of the input contains one integer $n$ $(3 \le n \le 200\,000)$ — the length of $s$.

The second line of the input contains the string $s$ of length $n$ consisting of lowercase Latin letters "a", "b" and "c" and question marks"?".

-----Output-----

Print the total number of subsequences "abc" in all strings you can obtain if you replace all question marks with letters "a", "b" and "c", modulo $10^{9} + 7$.

-----Examples-----
Input
6
ac?b?c

Output
24

Input
7
???????

Output
2835

Input
9
cccbbbaaa

Output
0

Input
5
a???c

Output
46

-----Note-----

In the first example, we can obtain $9$ strings:  "acabac" — there are $2$ subsequences "abc",  "acabbc" — there are $4$ subsequences "abc",  "acabcc" — there are $4$ subsequences "abc",  "acbbac" — there are $2$ subsequences "abc",  "acbbbc" — there are $3$ subsequences "abc",  "acbbcc" — there are $4$ subsequences "abc",  "accbac" — there is $1$ subsequence "abc",  "accbbc" — there are $2$ subsequences "abc",  "accbcc" — there are $2$ subsequences "abc".

So, there are $2 + 4 + 4 + 2 + 3 + 4 + 1 + 2 + 2 = 24$ subsequences "abc" in total.


You are given an undirected graph consisting of $n$ vertices. A number is written on each vertex; the number on vertex $i$ is $a_i$. Initially there are no edges in the graph.

You may add some edges to this graph, but you have to pay for them. The cost of adding an edge between vertices $x$ and $y$ is $a_x + a_y$ coins. There are also $m$ special offers, each of them is denoted by three numbers $x$, $y$ and $w$, and means that you can add an edge connecting vertices $x$ and $y$ and pay $w$ coins for it. You don't have to use special offers: if there is a pair of vertices $x$ and $y$ that has a special offer associated with it, you still may connect these two vertices paying $a_x + a_y$ coins for it.

What is the minimum number of coins you have to spend to make the graph connected? Recall that a graph is connected if it's possible to get from any vertex to any other vertex using only the edges belonging to this graph.

-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n \le 2 \cdot 10^5$, $0 \le m \le 2 \cdot 10^5$) — the number of vertices in the graph and the number of special offers, respectively.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^{12}$) — the numbers written on the vertices.

Then $m$ lines follow, each containing three integers $x$, $y$ and $w$ ($1 \le x, y \le n$, $1 \le w \le 10^{12}$, $x \ne y$) denoting a special offer: you may add an edge connecting vertex $x$ and vertex $y$, and this edge will cost $w$ coins.

-----Output-----

Print one integer — the minimum number of coins you have to pay to make the graph connected.

-----Examples-----
Input
3 2
1 3 3
2 3 5
2 1 1

Output
5

Input
4 0
1 3 3 7

Output
16

Input
5 4
1 2 3 4 5
1 2 8
1 3 10
1 4 7
1 5 15

Output
18

-----Note-----

In the first example it is possible to connect $1$ to $2$ using special offer $2$, and then $1$ to $3$ without using any offers.

In next two examples the optimal answer may be achieved without using special offers.


Polycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second.

Now it's raining, so some segments of his way are in the rain. Formally, it's raining on $n$ non-intersecting segments, the $i$-th segment which is in the rain is represented as $[l_i, r_i]$ ($0 \le l_i < r_i \le a$).

There are $m$ umbrellas lying on the line, the $i$-th umbrella is located at point $x_i$ ($0 \le x_i \le a$) and has weight $p_i$. When Polycarp begins his journey, he doesn't have any umbrellas.

During his journey from $x = 0$ to $x = a$ Polycarp can pick up and throw away umbrellas. Polycarp picks up and throws down any umbrella instantly. He can carry any number of umbrellas at any moment of time. Because Polycarp doesn't want to get wet, he must carry at least one umbrella while he moves from $x$ to $x + 1$ if a segment $[x, x + 1]$ is in the rain (i.e. if there exists some $i$ such that $l_i \le x$ and $x + 1 \le r_i$).

The condition above is the only requirement. For example, it is possible to go without any umbrellas to a point where some rain segment starts, pick up an umbrella at this point and move along with an umbrella. Polycarp can swap umbrellas while he is in the rain.

Each unit of length passed increases Polycarp's fatigue by the sum of the weights of umbrellas he carries while moving.

Can Polycarp make his way from point $x = 0$ to point $x = a$? If yes, find the minimum total fatigue after reaching $x = a$, if Polycarp picks up and throws away umbrellas optimally.

-----Input-----

The first line contains three integers $a$, $n$ and $m$ ($1 \le a, m \le 2000, 1 \le n \le \lceil\frac{a}{2}\rceil$) — the point at which Polycarp's friend lives, the number of the segments in the rain and the number of umbrellas.

Each of the next $n$ lines contains two integers $l_i$ and $r_i$ ($0 \le l_i < r_i \le a$) — the borders of the $i$-th segment under rain. It is guaranteed that there is no pair of intersecting segments. In other words, for each pair of segments $i$ and $j$ either $r_i < l_j$ or $r_j < l_i$.

Each of the next $m$ lines contains two integers $x_i$ and $p_i$ ($0 \le x_i \le a$, $1 \le p_i \le 10^5$) — the location and the weight of the $i$-th umbrella.

-----Output-----

Print "-1" (without quotes) if Polycarp can't make his way from point $x = 0$ to point $x = a$. Otherwise print one integer — the minimum total fatigue after reaching $x = a$, if Polycarp picks up and throws away umbrellas optimally.

-----Examples-----
Input
10 2 4
3 7
8 10
0 10
3 4
8 1
1 2

Output
14

Input
10 1 1
0 9
0 5

Output
45

Input
10 1 1
0 9
1 5

Output
-1

-----Note-----

In the first example the only possible strategy is to take the fourth umbrella at the point $x = 1$, keep it till the point $x = 7$ (the total fatigue at $x = 7$ will be equal to $12$), throw it away, move on from $x = 7$ to $x = 8$ without an umbrella, take the third umbrella at $x = 8$ and keep it till the end (the total fatigue at $x = 10$ will be equal to $14$).

In the second example the only possible strategy is to take the first umbrella, move with it till the point $x = 9$, throw it away and proceed without an umbrella till the end.


A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.
You will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.

-----Constraints-----
 - A, B, and C are all integers between 1 and 9 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
A B C

-----Output-----
If the given triple is poor, print Yes; otherwise, print No.

-----Sample Input-----
5 7 5

-----Sample Output-----
Yes

A and C are equal, but B is different from those two numbers, so this triple is poor.


A country decides to build a palace.
In this country, the average temperature of a point at an elevation of x meters is T-x \times 0.006 degrees Celsius.
There are N places proposed for the place. The elevation of Place i is H_i meters.
Among them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.
Print the index of the place where the palace should be built.
It is guaranteed that the solution is unique.

-----Constraints-----
 - 1 \leq N \leq 1000
 - 0 \leq T \leq 50
 - -60 \leq A \leq T
 - 0 \leq H_i \leq 10^5
 - All values in input are integers.
 - The solution is unique.

-----Input-----
Input is given from Standard Input in the following format:
N
T A
H_1 H_2 ... H_N

-----Output-----
Print the index of the place where the palace should be built.

-----Sample Input-----
2
12 5
1000 2000

-----Sample Output-----
1

 - The average temperature of Place 1 is 12-1000 \times 0.006=6 degrees Celsius.
 - The average temperature of Place 2 is 12-2000 \times 0.006=0 degrees Celsius.
Thus, the palace should be built at Place 1.


We have N+M balls, each of which has an integer written on it.

It is known that:
 - The numbers written on N of the balls are even.
 - The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.

It can be shown that this count does not depend on the actual values written on the balls.

-----Constraints-----
 - 0 \leq N,M \leq 100
 - 2 \leq N+M
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N M

-----Output-----
Print the answer.

-----Sample Input-----
2 1

-----Sample Output-----
1

For example, let us assume that the numbers written on the three balls are 1,2,4.
 - If we choose the two balls with 1 and 2, the sum is odd;
 - If we choose the two balls with 1 and 4, the sum is odd;
 - If we choose the two balls with 2 and 4, the sum is even.
Thus, the answer is 1.


You are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:
 - Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times does AC occurs as a substring?

-----Notes-----
A substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.
For example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and  (the empty string), but not AC.

-----Constraints-----
 - 2 \leq N \leq 10^5
 - 1 \leq Q \leq 10^5
 - S is a string of length N.
 - Each character in S is A, C, G or T.
 - 1 \leq l_i < r_i \leq N

-----Input-----
Input is given from Standard Input in the following format:
N Q
S
l_1 r_1
:
l_Q r_Q

-----Output-----
Print Q lines. The i-th line should contain the answer to the i-th query.

-----Sample Input-----
8 3
ACACTACG
3 7
2 3
1 8

-----Sample Output-----
2
0
3

 - Query 1: the substring of S starting at index 3 and ending at index 7 is ACTAC. In this string, AC occurs twice as a substring.
 - Query 2: the substring of S starting at index 2 and ending at index 3 is CA. In this string, AC occurs zero times as a substring.
 - Query 3: the substring of S starting at index 1 and ending at index 8 is ACACTACG. In this string, AC occurs three times as a substring.


A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.

-----Constraints-----
 - 1 \leq K \leq N \leq 1000
 - 1 \leq p_i \leq 1000
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N

-----Output-----
Print an integer representing the minimum possible total price of fruits.

-----Sample Input-----
5 3
50 100 80 120 80

-----Sample Output-----
210

This shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.
The minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.


There are three airports A, B and C, and flights between each pair of airports in both directions.
A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.
Consider a route where we start at one of the airports, fly to another airport and then fly to the other airport.
What is the minimum possible sum of the flight times?

-----Constraints-----
 - 1 \leq P,Q,R \leq 100
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
P Q R

-----Output-----
Print the minimum possible sum of the flight times.

-----Sample Input-----
1 3 4

-----Sample Output-----
4

 - The sum of the flight times in the route A \rightarrow B \rightarrow C: 1 + 3 = 4 hours
 - The sum of the flight times in the route A \rightarrow C \rightarrow C: 4 + 3 = 7 hours
 - The sum of the flight times in the route B \rightarrow A \rightarrow C: 1 + 4 = 5 hours
 - The sum of the flight times in the route B \rightarrow C \rightarrow A: 3 + 4 = 7 hours
 - The sum of the flight times in the route C \rightarrow A \rightarrow B: 4 + 1 = 5 hours
 - The sum of the flight times in the route C \rightarrow B \rightarrow A: 3 + 1 = 4 hours
The minimum of these is 4 hours.


X and A are integers between 0 and 9 (inclusive).
If X is less than A, print 0; if X is not less than A, print 10.

-----Constraints-----
 - 0 \leq X, A \leq 9
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
X A

-----Output-----
If X is less than A, print 0; if X is not less than A, print 10.

-----Sample Input-----
3 5

-----Sample Output-----
0

3 is less than 5, so we should print 0.


Given any integer x, Aoki can do the operation below.
Operation: Replace x with the absolute difference of x and K.
You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

-----Constraints-----
 - 0 ≤ N ≤ 10^{18}
 - 1 ≤ K ≤ 10^{18}
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N K

-----Output-----
Print the minimum possible value taken by N after Aoki does the operation zero or more times.

-----Sample Input-----
7 4

-----Sample Output-----
1

Initially, N=7.
After one operation, N becomes |7-4| = 3.
After two operations, N becomes |3-4| = 1, which is the minimum value taken by N.


Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.

-----Constraints-----
 - 1 \leq A_i \leq 13 \ \ (i=1,2,3)
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
A_1 A_2 A_3

-----Output-----
If A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.

-----Sample Input-----
5 7 9

-----Sample Output-----
win

5+7+9=21, so print win.


You are given a positive integer N.
Find the minimum positive integer divisible by both 2 and N.

-----Constraints-----
 - 1 \leq N \leq 10^9
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
Print the minimum positive integer divisible by both 2 and N.

-----Sample Input-----
3

-----Sample Output-----
6

6 is divisible by both 2 and 3.
Also, there is no positive integer less than 6 that is divisible by both 2 and 3.
Thus, the answer is 6.


There are N apple trees in a row. People say that one of them will bear golden apples.
We want to deploy some number of inspectors so that each of these trees will be inspected.
Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the objective.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 20
 - 1 \leq D \leq 20

-----Input-----
Input is given from Standard Input in the following format:
N D

-----Output-----
Print the minimum number of inspectors that we need to deploy to achieve the objective.

-----Sample Input-----
6 2

-----Sample Output-----
2

We can achieve the objective by, for example, placing an inspector under Tree 3 and Tree 4.


The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.
When counting pencils in Japanese, the counter word "本" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of "本" in the phrase "N 本" for a positive integer N not exceeding 999 is as follows:
 - hon when the digit in the one's place of N is 2, 4, 5, 7, or 9;
 - pon when the digit in the one's place of N is 0, 1, 6 or 8;
 - bon when the digit in the one's place of N is 3.
Given N, print the pronunciation of "本" in the phrase "N 本".

-----Constraints-----
 - N is a positive integer not exceeding 999.

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
Print the answer.

-----Sample Input-----
16

-----Sample Output-----
pon

The digit in the one's place of 16 is 6, so the "本" in "16 本" is pronounced pon.


It's now the season of TAKOYAKI FESTIVAL!
This year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.
As is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \times y health points.
There are \frac{N \times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \frac{N \times (N - 1)}{2} values.

-----Constraints-----
 - All values in input are integers.
 - 2 \leq N \leq 50
 - 0 \leq d_i \leq 100

-----Input-----
Input is given from Standard Input in the following format:
N
d_1 d_2 ... d_N

-----Output-----
Print the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.

-----Sample Input-----
3
3 1 2

-----Sample Output-----
11

There are three possible choices:
 - Eat the first and second takoyaki. You will restore 3 health points.
 - Eat the second and third takoyaki. You will restore 2 health points.
 - Eat the first and third takoyaki. You will restore 6 health points.
The sum of these values is 11.


You are given a sequence of length N: A_1, A_2, ..., A_N.
For each integer i between 1 and N (inclusive), answer the following question:
 - Find the maximum value among the N-1 elements other than A_i in the sequence.

-----Constraints-----
 - 2 \leq N \leq 200000
 - 1 \leq A_i \leq 200000
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
A_1
:
A_N

-----Output-----
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.

-----Sample Input-----
3
1
4
3

-----Sample Output-----
4
3
4

 - The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.
 - The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.
 - The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.


There are two buttons, one of size A and one of size B.
When you press a button of size X, you get X coins and the size of that button decreases by 1.
You will press a button twice. Here, you can press the same button twice, or press both buttons once.
At most how many coins can you get?

-----Constraints-----
 - All values in input are integers.
 - 3 \leq A, B \leq 20

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
Print the maximum number of coins you can get.

-----Sample Input-----
5 3

-----Sample Output-----
9

You can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.


There are N candles placed on a number line.
The i-th candle from the left is placed on coordinate x_i.
Here, x_1 < x_2 < ... < x_N holds.
Initially, no candles are burning.
Snuke decides to light K of the N candles.
Now, he is at coordinate 0.
He can move left and right along the line with speed 1.
He can also light a candle when he is at the same position as the candle, in negligible time.
Find the minimum time required to light K candles.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - 1 \leq K \leq N
 - x_i is an integer.
 - |x_i| \leq 10^8
 - x_1 < x_2 < ... < x_N

-----Input-----
Input is given from Standard Input in the following format:
N K
x_1 x_2 ... x_N

-----Output-----
Print the minimum time required to light K candles.

-----Sample Input-----
5 3
-30 -10 10 20 50

-----Sample Output-----
40

He should move and light candles as follows:
 - Move from coordinate 0 to -10.
 - Light the second candle from the left.
 - Move from coordinate -10 to 10.
 - Light the third candle from the left.
 - Move from coordinate 10 to 20.
 - Light the fourth candle from the left.


In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.
It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.
Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.
Assume also that the depth of the snow cover is always at least 1 meter.

-----Constraints-----
 - 1 \leq a < b < 499500(=1+2+3+...+999)
 - All values in input are integers.
 - There is no input that contradicts the assumption.

-----Input-----
Input is given from Standard Input in the following format:
a b

-----Output-----
If the depth of the snow cover is x meters, print x as an integer.

-----Sample Input-----
8 13

-----Sample Output-----
2

The heights of the two towers are 10 meters and 15 meters, respectively.
Thus, we can see that the depth of the snow cover is 2 meters.


Serval is fighting with a monster.
The health of the monster is H.
In one attack, Serval can decrease the monster's health by A.
There is no other way to decrease the monster's health.
Serval wins when the monster's health becomes 0 or below.
Find the number of attacks Serval needs to make before winning.

-----Constraints-----
 - 1 \leq H \leq 10^4
 - 1 \leq A \leq 10^4
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
H A

-----Output-----
Print the number of attacks Serval needs to make before winning.

-----Sample Input-----
10 4

-----Sample Output-----
3

 - After one attack, the monster's health will be 6.
 - After two attacks, the monster's health will be 2.
 - After three attacks, the monster's health will be -2.
Thus, Serval needs to make three attacks to win.


Alice and Bob are controlling a robot. They each have one switch that controls the robot.

Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.

Bob started holding down his button C second after the start-up, and released his button D second after the start-up.

For how many seconds both Alice and Bob were holding down their buttons?

-----Constraints-----
 - 0≤A<B≤100
 - 0≤C<D≤100
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
A B C D

-----Output-----
Print the length of the duration (in seconds) in which both Alice and Bob were holding down their buttons.

-----Sample Input-----
0 75 25 100

-----Sample Output-----
50

Alice started holding down her button 0 second after the start-up of the robot, and released her button 75 second after the start-up.

Bob started holding down his button 25 second after the start-up, and released his button 100 second after the start-up.

Therefore, the time when both of them were holding down their buttons, is the 50 seconds from 25 seconds after the start-up to 75 seconds after the start-up.


The number 105 is quite special - it is odd but still it has eight divisors.
Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?

-----Constraints-----
 - N is an integer between 1 and 200 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
Print the count.

-----Sample Input-----
105

-----Sample Output-----
1

Among the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.


Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.
When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.

-----Constraints-----
 - 1 \leq N,K \leq 100
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N K

-----Output-----
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.

-----Sample Input-----
7 3

-----Sample Output-----
1

When the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.