Let's define a split of $$$n$$$ as a nonincreasing sequence of positive integers, the sum of which is $$$n$$$. For example, the following sequences are splits of $$$8$$$: $$$[4, 4]$$$, $$$[3, 3, 2]$$$, $$$[2, 2, 1, 1, 1, 1]$$$, $$$[5, 2, 1]$$$.The following sequences aren't splits of $$$8$$$: $$$[1, 7]$$$, $$$[5, 4]$$$, $$$[11, -3]$$$, $$$[1, 1, 4, 1, 1]$$$.The weight of a split is the number of elements in the split that are equal to the first element. For example, the weight of the split $$$[1, 1, 1, 1, 1]$$$ is $$$5$$$, the weight of the split $$$[5, 5, 3, 3, 3]$$$ is $$$2$$$ and the weight of the split $$$[9]$$$ equals $$$1$$$.For a given $$$n$$$, find out the number of different weights of its splits.

The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^9$$$).

Output one integer — the answer to the problem.

NoteIn the first sample, there are following possible weights of splits of $$$7$$$:Weight 1: [$$$\textbf 7$$$] Weight 2: [$$$\textbf 3$$$, $$$\textbf 3$$$, 1] Weight 3: [$$$\textbf 2$$$, $$$\textbf 2$$$, $$$\textbf 2$$$, 1] Weight 7: [$$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$]


HQ9+ is a joke programming language which has only four one-character instructions: "H" prints "Hello, World!", "Q" prints the source code of the program itself, "9" prints the lyrics of "99 Bottles of Beer" song,  "+" increments the value stored in the internal accumulator.Instructions "H" and "Q" are case-sensitive and must be uppercase. The characters of the program which are not instructions are ignored.You are given a program written in HQ9+. You have to figure out whether executing this program will produce any output.

The input will consist of a single line p which will give a program in HQ9+. String p will contain between 1 and 100 characters, inclusive. ASCII-code of each character of p will be between 33 (exclamation mark) and 126 (tilde), inclusive.

Output "YES", if executing the program will produce any output, and "NO" otherwise.

NoteIn the first case the program contains only one instruction — "H", which prints "Hello, World!".In the second case none of the program characters are language instructions.


One day Vasya heard a story: "In the city of High Bertown a bus number 62 left from the bus station. It had n grown-ups and m kids..."The latter events happen to be of no importance to us. Vasya is an accountant and he loves counting money. So he wondered what maximum and minimum sum of money these passengers could have paid for the ride.The bus fare equals one berland ruble in High Bertown. However, not everything is that easy — no more than one child can ride for free with each grown-up passenger. That means that a grown-up passenger who rides with his k (k > 0) children, pays overall k rubles: a ticket for himself and (k - 1) tickets for his children. Also, a grown-up can ride without children, in this case he only pays one ruble.We know that in High Bertown children can't ride in a bus unaccompanied by grown-ups.Help Vasya count the minimum and the maximum sum in Berland rubles, that all passengers of this bus could have paid in total.

The input file consists of a single line containing two space-separated numbers n and m (0 ≤ n, m ≤ 105) — the number of the grown-ups and the number of the children in the bus, correspondingly.

If n grown-ups and m children could have ridden in the bus, then print on a single line two space-separated integers — the minimum and the maximum possible total bus fare, correspondingly.  Otherwise, print "Impossible" (without the quotes).

NoteIn the first sample a grown-up rides with two children and pays two rubles.In the second sample there are only children in the bus, so the situation is impossible. In the third sample there are two cases:  Each of the two grown-ups rides with one children and pays one ruble for the tickets. In this case the passengers pay two rubles in total.  One of the grown-ups ride with two children's and pays two rubles, the another one rides alone and pays one ruble for himself. So, they pay three rubles in total.


There are n types of coins in Byteland. Conveniently, the denomination of the coin type k divides the denomination of the coin type k + 1, the denomination of the coin type 1 equals 1 tugrick. The ratio of the denominations of coin types k + 1 and k equals ak. It is known that for each x there are at most 20 coin types of denomination x.Byteasar has bk coins of type k with him, and he needs to pay exactly m tugricks. It is known that Byteasar never has more than 3·105 coins with him. Byteasar want to know how many ways there are to pay exactly m tugricks. Two ways are different if there is an integer k such that the amount of coins of type k differs in these two ways. As all Byteland citizens, Byteasar wants to know the number of ways modulo 109 + 7.

The first line contains single integer n (1 ≤ n ≤ 3·105) — the number of coin types. The second line contains n - 1 integers a1, a2, ..., an - 1 (1 ≤ ak ≤ 109) — the ratios between the coin types denominations. It is guaranteed that for each x there are at most 20 coin types of denomination x. The third line contains n non-negative integers b1, b2, ..., bn — the number of coins of each type Byteasar has. It is guaranteed that the sum of these integers doesn't exceed 3·105. The fourth line contains single integer m (0 ≤ m < 1010000) — the amount in tugricks Byteasar needs to pay.

Print single integer — the number of ways to pay exactly m tugricks modulo 109 + 7.

NoteIn the first example Byteasar has 4 coins of denomination 1, and he has to pay 2 tugricks. There is only one way.In the second example Byteasar has 4 coins of each of two different types of denomination 1, he has to pay 2 tugricks. There are 3 ways: pay one coin of the first type and one coin of the other, pay two coins of the first type, and pay two coins of the second type.In the third example the denominations are equal to 1, 3, 9.


Earlier, when there was no Internet, each bank had a lot of offices all around Bankopolis, and it caused a lot of problems. Namely, each day the bank had to collect cash from all the offices.Once Oleg the bank client heard a dialogue of two cash collectors. Each day they traveled through all the departments and offices of the bank following the same route every day. The collectors started from the central department and moved between some departments or between some department and some office using special roads. Finally, they returned to the central department. The total number of departments and offices was n, the total number of roads was n - 1. In other words, the special roads system was a rooted tree in which the root was the central department, the leaves were offices, the internal vertices were departments. The collectors always followed the same route in which the number of roads was minimum possible, that is 2n - 2.One of the collectors said that the number of offices they visited between their visits to offices a and then b (in the given order) is equal to the number of offices they visited between their visits to offices b and then a (in this order). The other collector said that the number of offices they visited between their visits to offices c and then d (in this order) is equal to the number of offices they visited between their visits to offices d and then c (in this order). The interesting part in this talk was that the shortest path (using special roads only) between any pair of offices among a, b, c and d passed through the central department.Given the special roads map and the indexes of offices a, b, c and d, determine if the situation described by the collectors was possible, or not.

The first line contains single integer n (5 ≤ n ≤ 5000) — the total number of offices and departments. The departments and offices are numbered from 1 to n, the central office has index 1. The second line contains four integers a, b, c and d (2 ≤ a, b, c, d ≤ n) — the indexes of the departments mentioned in collector's dialogue. It is guaranteed that these indexes are offices (i.e. leaves of the tree), not departments. It is guaranteed that the shortest path between any pair of these offices passes through the central department. On the third line n - 1 integers follow: p2, p3, ..., pn (1 ≤ pi < i), where pi denotes that there is a special road between the i-th office or department and the pi-th department. Please note the joint enumeration of departments and offices. It is guaranteed that the given graph is a tree. The offices are the leaves, the departments are the internal vertices.

If the situation described by the cash collectors was possible, print "YES". Otherwise, print "NO".

NoteIn the first example the following collector's route was possible: . We can note that between their visits to offices a and b the collectors visited the same number of offices as between visits to offices b and a; the same holds for c and d (the collectors' route is infinite as they follow it each day).In the second example there is no route such that between their visits to offices c and d the collectors visited the same number of offices as between visits to offices d and c. Thus, there situation is impossible. In the third example one of the following routes is: .


It's been long after the events of the previous problems, and Karen has now moved on from student life and is looking to relocate to a new neighborhood.  The neighborhood consists of n houses in a straight line, labelled 1 to n from left to right, all an equal distance apart.Everyone in this neighborhood loves peace and quiet. Because of this, whenever a new person moves into the neighborhood, he or she always chooses the house whose minimum distance to any occupied house is maximized. If there are multiple houses with the maximum possible minimum distance, he or she chooses the leftmost one.Note that the first person to arrive always moves into house 1.Karen is the k-th person to enter this neighborhood. If everyone, including herself, follows this rule, which house will she move into?

The first and only line of input contains two integers, n and k (1 ≤ k ≤ n ≤ 1018), describing the number of houses in the neighborhood, and that Karen was the k-th person to move in, respectively.

Output a single integer on a line by itself, the label of the house Karen will move into.

NoteIn the first test case, there are 6 houses in the neighborhood, and Karen is the fourth person to move in:  The first person moves into house 1.  The second person moves into house 6.  The third person moves into house 3.  The fourth person moves into house 2. In the second test case, there are 39 houses in the neighborhood, and Karen is the third person to move in:  The first person moves into house 1.  The second person moves into house 39.  The third person moves into house 20.


Alice and Bob have decided to play the game "Rock, Paper, Scissors". The game consists of several rounds, each round is independent of each other. In each round, both players show one of the following things at the same time: rock, paper or scissors. If both players showed the same things then the round outcome is a draw. Otherwise, the following rules applied:  if one player showed rock and the other one showed scissors, then the player who showed rock is considered the winner and the other one is considered the loser;  if one player showed scissors and the other one showed paper, then the player who showed scissors is considered the winner and the other one is considered the loser;  if one player showed paper and the other one showed rock, then the player who showed paper is considered the winner and the other one is considered the loser. Alice and Bob decided to play exactly $$$n$$$ rounds of the game described above. Alice decided to show rock $$$a_1$$$ times, show scissors $$$a_2$$$ times and show paper $$$a_3$$$ times. Bob decided to show rock $$$b_1$$$ times, show scissors $$$b_2$$$ times and show paper $$$b_3$$$ times. Though, both Alice and Bob did not choose the sequence in which they show things. It is guaranteed that $$$a_1 + a_2 + a_3 = n$$$ and $$$b_1 + b_2 + b_3 = n$$$.Your task is to find two numbers:  the minimum number of round Alice can win;  the maximum number of rounds Alice can win.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$) — the number of rounds. The second line of the input contains three integers $$$a_1, a_2, a_3$$$ ($$$0 \le a_i \le n$$$) — the number of times Alice will show rock, scissors and paper, respectively. It is guaranteed that $$$a_1 + a_2 + a_3 = n$$$. The third line of the input contains three integers $$$b_1, b_2, b_3$$$ ($$$0 \le b_j \le n$$$) — the number of times Bob will show rock, scissors and paper, respectively. It is guaranteed that $$$b_1 + b_2 + b_3 = n$$$.

Print two integers: the minimum and the maximum number of rounds Alice can win.

NoteIn the first example, Alice will not win any rounds if she shows scissors and then paper and Bob shows rock and then scissors. In the best outcome, Alice will win one round if she shows paper and then scissors, and Bob shows rock and then scissors.In the second example, Alice will not win any rounds if Bob shows the same things as Alice each round.In the third example, Alice always shows paper and Bob always shows rock so Alice will win all three rounds anyway.


Limak is a little polar bear. He has n balls, the i-th ball has size ti.Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy:  No two friends can get balls of the same size.  No two friends can get balls of sizes that differ by more than 2. For example, Limak can choose balls with sizes 4, 5 and 3, or balls with sizes 90, 91 and 92. But he can't choose balls with sizes 5, 5 and 6 (two friends would get balls of the same size), and he can't choose balls with sizes 30, 31 and 33 (because sizes 30 and 33 differ by more than 2).Your task is to check whether Limak can choose three balls that satisfy conditions above.

The first line of the input contains one integer n (3 ≤ n ≤ 50) — the number of balls Limak has. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 1000) where ti denotes the size of the i-th ball.

Print "YES" (without quotes) if Limak can choose three balls of distinct sizes, such that any two of them differ by no more than 2. Otherwise, print "NO" (without quotes).

NoteIn the first sample, there are 4 balls and Limak is able to choose three of them to satisfy the rules. He must must choose balls with sizes 18, 16 and 17.In the second sample, there is no way to give gifts to three friends without breaking the rules.In the third sample, there is even more than one way to choose balls:  Choose balls with sizes 3, 4 and 5.  Choose balls with sizes 972, 970, 971.


A monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times b, b + a, b + 2a, b + 3a, ... and Morty screams at times d, d + c, d + 2c, d + 3c, ....   The Monster will catch them if at any point they scream at the same time, so it wants to know when it will catch them (the first time they scream at the same time) or that they will never scream at the same time.

The first line of input contains two integers a and b (1 ≤ a, b ≤ 100).  The second line contains two integers c and d (1 ≤ c, d ≤ 100).

Print the first time Rick and Morty will scream at the same time, or  - 1 if they will never scream at the same time.

NoteIn the first sample testcase, Rick's 5th scream and Morty's 8th time are at time 82. In the second sample testcase, all Rick's screams will be at odd times and Morty's will be at even times, so they will never scream at the same time.


You have a set of $$$n$$$ weights. You know that their masses are $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ grams, but you don't know which of them has which mass. You can't distinguish the weights.However, your friend does know the mass of each weight. You can ask your friend to give you exactly $$$k$$$ weights with the total mass $$$m$$$ (both parameters $$$k$$$ and $$$m$$$ are chosen by you), and your friend will point to any valid subset of weights, if it is possible.You are allowed to make this query only once. Find the maximum possible number of weights you can reveal after this query.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of weights. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 100$$$) — the masses of the weights.

Print the maximum number of weights you can learn the masses for after making a single query.

NoteIn the first example we can ask for a subset of two weights with total mass being equal to $$$4$$$, and the only option is to get $$$\{2, 2\}$$$.Another way to obtain the same result is to ask for a subset of two weights with the total mass of $$$5$$$ and get $$$\{1, 4\}$$$. It is easy to see that the two remaining weights have mass of $$$2$$$ grams each.In the second example we can ask for a subset of two weights with total mass being $$$8$$$, and the only answer is $$$\{4, 4\}$$$. We can prove it is not possible to learn masses for three weights in one query, but we won't put the proof here.


qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf.

jxu ydfkj sediyiji ev q iydwbu ydjuwuh d (1 ≤ d ≤ 11184) — jxu edu-rqiut ydtun ev jxu ucyhf je vydt.


Valera came to Japan and bought many robots for his research. He's already at the airport, the plane will fly very soon and Valera urgently needs to bring all robots to the luggage compartment.The robots are self-propelled (they can potentially move on their own), some of them even have compartments to carry other robots. More precisely, for the i-th robot we know value ci — the number of robots it can carry. In this case, each of ci transported robots can additionally carry other robots.However, the robots need to be filled with fuel to go, so Valera spent all his last money and bought S liters of fuel. He learned that each robot has a restriction on travel distances. Thus, in addition to features ci, the i-th robot has two features fi and li — the amount of fuel (in liters) needed to move the i-th robot, and the maximum distance that the robot can go.Due to the limited amount of time and fuel, Valera wants to move the maximum number of robots to the luggage compartment. He operates as follows.   First Valera selects some robots that will travel to the luggage compartment on their own. In this case the total amount of fuel required to move all these robots must not exceed S.  Then Valera seats the robots into the compartments, so as to transport as many robots as possible. Note that if a robot doesn't move by itself, you can put it in another not moving robot that is moved directly or indirectly by a moving robot.  After that all selected and seated robots along with Valera go to the luggage compartment and the rest robots will be lost. There are d meters to the luggage compartment. Therefore, the robots that will carry the rest, must have feature li of not less than d. During the moving Valera cannot stop or change the location of the robots in any way.Help Valera calculate the maximum number of robots that he will be able to take home, and the minimum amount of fuel he will have to spend, because the remaining fuel will come in handy in Valera's research.

The first line contains three space-separated integers n, d, S (1 ≤ n ≤ 105, 1 ≤ d, S ≤ 109). The first number represents the number of robots, the second one — the distance to the luggage compartment and the third one — the amount of available fuel. Next n lines specify the robots. The i-th line contains three space-separated integers ci, fi, li (0 ≤ ci, fi, li ≤ 109) — the i-th robot's features. The first number is the number of robots the i-th robot can carry, the second number is the amount of fuel needed for the i-th robot to move and the third one shows the maximum distance the i-th robot can go.

Print two space-separated integers — the maximum number of robots Valera can transport to the luggage compartment and the minimum amount of fuel he will need for that. If Valera won't manage to get any robots to the luggage compartment, print two zeroes.


After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one from the first column and the other from the second column, such that their sum is divisible by 5.Formally, Alyona wants to count the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and  equals 0.As usual, Alyona has some troubles and asks you to help.

The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1 000 000).

Print the only integer — the number of pairs of integers (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m and (x + y) is divisible by 5.

NoteFollowing pairs are suitable in the first sample case:   for x = 1 fits y equal to 4 or 9;  for x = 2 fits y equal to 3 or 8;  for x = 3 fits y equal to 2, 7 or 12;  for x = 4 fits y equal to 1, 6 or 11;  for x = 5 fits y equal to 5 or 10;  for x = 6 fits y equal to 4 or 9. Only the pair (1, 4) is suitable in the third sample case.


One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2. The author would need to spend too much time and effort to make the sum of his marks strictly more than k. That could have spoilt the Codeforces round. On the other hand, if the sum of his marks is strictly less than k, the author's mum won't be pleased at all. The Codeforces authors are very smart and they always get the mark they choose themselves. Also, the Codeforces authors just hate re-sitting exams. Help the author and find the minimum number of exams he will have to re-sit if he passes the exams in the way that makes the sum of marks for all n exams equal exactly k.

The single input line contains space-separated integers n and k (1 ≤ n ≤ 50, 1 ≤ k ≤ 250) — the number of exams and the required sum of marks. It is guaranteed that there exists a way to pass n exams in the way that makes the sum of marks equal exactly k.

Print the single number — the minimum number of exams that the author will get a 2 for, considering that the sum of marks for all exams must equal k.

NoteIn the first sample the author has to get a 2 for all his exams.In the second sample he should get a 3 for two exams and a 2 for two more.In the third sample he should get a 3 for one exam.


Little C loves number «3» very much. He loves all things about it.Now he is playing a game on a chessboard of size $$$n \times m$$$. The cell in the $$$x$$$-th row and in the $$$y$$$-th column is called $$$(x,y)$$$. Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between which is exactly $$$3$$$. The Manhattan distance between two cells $$$(x_i,y_i)$$$ and $$$(x_j,y_j)$$$ is defined as $$$|x_i-x_j|+|y_i-y_j|$$$.He want to place as many chessmen as possible on the chessboard. Please help him find the maximum number of chessmen he can place.

A single line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n,m \leq 10^9$$$) — the number of rows and the number of columns of the chessboard.

Print one integer — the maximum number of chessmen Little C can place.

NoteIn the first example, the Manhattan distance between any two cells is smaller than $$$3$$$, so the answer is $$$0$$$.In the second example, a possible solution is $$$(1,1)(3,2)$$$, $$$(1,2)(3,3)$$$, $$$(2,1)(1,3)$$$, $$$(3,1)(2,3)$$$.


InputThe only line of the input contains a 7-digit hexadecimal number. The first "digit" of the number is letter A, the rest of the "digits" are decimal digits 0-9.OutputOutput a single integer.ExamplesInput
A278832
Output
0
Input
A089956
Output
0
Input
A089957
Output
1
Input
A144045
Output
1


In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.You are given two strings s1, s2 and another string called virus. Your task is to find the longest common subsequence of s1 and s2, such that it doesn't contain virus as a substring.

The input contains three strings in three separate lines: s1, s2 and virus (1 ≤ |s1|, |s2|, |virus| ≤ 100). Each string consists only of uppercase English letters.

Output the longest common subsequence of s1 and s2 without virus as a substring. If there are multiple answers, any of them will be accepted.  If there is no valid common subsequence, output 0.


Nauuo is a girl who loves writing comments.One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.It's known that there were $$$x$$$ persons who would upvote, $$$y$$$ persons who would downvote, and there were also another $$$z$$$ persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the $$$x+y+z$$$ people would vote exactly one time.There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".Because of the $$$z$$$ unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the $$$z$$$ persons vote, that the results are different in the two situations.Tell Nauuo the result or report that the result is uncertain.

The only line contains three integers $$$x$$$, $$$y$$$, $$$z$$$ ($$$0\le x,y,z\le100$$$), corresponding to the number of persons who would upvote, downvote or unknown.

If there is only one possible result, print the result : "+", "-" or "0". Otherwise, print "?" to report that the result is uncertain.

NoteIn the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.


Ayoub had an array $$$a$$$ of integers of size $$$n$$$ and this array had two interesting properties:   All the integers in the array were between $$$l$$$ and $$$r$$$ (inclusive).  The sum of all the elements was divisible by $$$3$$$. Unfortunately, Ayoub has lost his array, but he remembers the size of the array $$$n$$$ and the numbers $$$l$$$ and $$$r$$$, so he asked you to find the number of ways to restore the array. Since the answer could be very large, print it modulo $$$10^9 + 7$$$ (i.e. the remainder when dividing by $$$10^9 + 7$$$). In case there are no satisfying arrays (Ayoub has a wrong memory), print $$$0$$$.

The first and only line contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$1 \le n \le 2 \cdot 10^5 , 1 \le l \le r \le 10^9$$$) — the size of the lost array and the range of numbers in the array.

Print the remainder when dividing by $$$10^9 + 7$$$ the number of ways to restore the array.

NoteIn the first example, the possible arrays are : $$$[1,2], [2,1], [3, 3]$$$.In the second example, the only possible array is $$$[2, 2, 2]$$$.


You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.Consider positive integers a, a + 1, ..., b (a ≤ b). You want to find the minimum integer l (1 ≤ l ≤ b - a + 1) such that for any integer x (a ≤ x ≤ b - l + 1) among l integers x, x + 1, ..., x + l - 1 there are at least k prime numbers. Find and print the required minimum l. If no value l meets the described limitations, print -1.

A single line contains three space-separated integers a, b, k (1 ≤ a, b, k ≤ 106; a ≤ b).

In a single line print a single integer — the required minimum l. If there's no solution, print -1.


n evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or more points which are evenly spaced, and either increase all numbers at points in the set by k or decrease all numbers at points in the set by k. You would like to eventually end up with all numbers equal to 0. Is it possible?A set of 2 points is considered evenly spaced if they are diametrically opposed, and a set of 3 or more points is considered evenly spaced if they form a regular polygon.

The first line of input contains an integer n (3 ≤ n ≤ 100000), the number of points along the circle. The following line contains a string s with exactly n digits, indicating the numbers initially present at each of the points, in clockwise order.

Print "YES" (without quotes) if there is some sequence of operations that results in all numbers being 0, otherwise "NO" (without quotes). You can print each letter in any case (upper or lower).

NoteIf we label the points from 1 to n, then for the first test case we can set k = 1. Then we increase the numbers at points 7 and 22 by 1, then decrease the numbers at points 7, 17, and 27 by 1, then decrease the numbers at points 4, 10, 16, 22, and 28 by 1.


While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way:  Together with his old phone, he lost all his contacts and now he can only remember the way his fingers moved when he put some number in. One can formally consider finger movements as a sequence of vectors connecting centers of keys pressed consecutively to put in a number. For example, the finger movements for number "586" are the same as finger movements for number "253":    Mike has already put in a number by his "finger memory" and started calling it, so he is now worrying, can he be sure that he is calling the correct number? In other words, is there any other number, that has the same finger movements?

The first line of the input contains the only integer n (1 ≤ n ≤ 9) — the number of digits in the phone number that Mike put in. The second line contains the string consisting of n digits (characters from '0' to '9') representing the number that Mike put in.

If there is no other phone number with the same finger movements and Mike can be sure he is calling the correct number, print "YES" (without quotes) in the only line. Otherwise print "NO" (without quotes) in the first line.

NoteYou can find the picture clarifying the first sample case in the statement above.


This is an interactive problem. In the interaction section below you will find the information about flushing the output.The New Year tree of height h is a perfect binary tree with vertices numbered 1 through 2h - 1 in some order. In this problem we assume that h is at least 2. The drawing below shows one example New Year tree of height 3:  Polar bears love decorating the New Year tree and Limak is no exception. To decorate the tree, he must first find its root, i.e. a vertex with exactly two neighbours (assuming that h ≥ 2). It won't be easy because Limak is a little bear and he doesn't even see the whole tree. Can you help him?There are t testcases. In each testcase, you should first read h from the input. Then you can ask at most 16 questions of format "? x" (without quotes), where x is an integer between 1 and 2h - 1, inclusive. As a reply you will get the list of neighbours of vertex x (more details in the "Interaction" section below). For example, for a tree on the drawing above after asking "? 1" you would get a response with 3 neighbours: 4, 5 and 7. Your goal is to find the index of the root y and print it in the format "! y". You will be able to read h for a next testcase only after printing the answer in a previous testcase and flushing the output.Each tree is fixed from the beginning and it doesn't change during your questions.

The first line of the input contains a single integer t (1 ≤ t ≤ 500) — the number of testcases. At the beginning of each testcase you should read from the input a single integer h (2 ≤ h ≤ 7) — the height of the tree. You can't read the value of h in a next testcase until you answer a previous testcase.

NoteIn the first sample, a tree corresponds to the drawing from the statement.In the second sample, there are two two testcases. A tree in the first testcase has height 2 and thus 3 vertices. A tree in the second testcase has height 4 and thus 15 vertices. You can see both trees on the drawing below.


Little Elephant loves magic squares very much.A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns and diagonals equals 15.  The Little Elephant remembered one magic square. He started writing this square on a piece of paper, but as he wrote, he forgot all three elements of the main diagonal of the magic square. Fortunately, the Little Elephant clearly remembered that all elements of the magic square did not exceed 105. Help the Little Elephant, restore the original magic square, given the Elephant's notes.

The first three lines of the input contain the Little Elephant's notes. The first line contains elements of the first row of the magic square. The second line contains the elements of the second row, the third line is for the third row. The main diagonal elements that have been forgotten by the Elephant are represented by zeroes. It is guaranteed that the notes contain exactly three zeroes and they are all located on the main diagonal. It is guaranteed that all positive numbers in the table do not exceed 105.

Print three lines, in each line print three integers — the Little Elephant's magic square. If there are multiple magic squares, you are allowed to print any of them. Note that all numbers you print must be positive and not exceed 105. It is guaranteed that there exists at least one magic square that meets the conditions.


The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.Check the king's moves here https://en.wikipedia.org/wiki/King_(chess).  King moves from the position e4

The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'.

Print the only integer x — the number of moves permitted for the king.


Igor the analyst is at work. He learned about a feature in his text editor called "Replace All". Igor is too bored at work and thus he came up with the following problem:Given two strings x and y which consist of the English letters 'A' and 'B' only, a pair of strings (s, t) is called good if: s and t consist of the characters '0' and '1' only. 1 ≤ |s|, |t| ≤ n, where |z| denotes the length of string z, and n is a fixed positive integer. If we replace all occurrences of 'A' in x and y with the string s, and replace all occurrences of 'B' in x and y with the string t, then the two obtained from x and y strings are equal. For example, if x = AAB, y = BB and n = 4, then (01, 0101) is one of good pairs of strings, because both obtained after replacing strings are "01010101".The flexibility of a pair of strings x and y is the number of pairs of good strings (s, t). The pairs are ordered, for example the pairs (0, 1) and (1, 0) are different.You're given two strings c and d. They consist of characters 'A', 'B' and '?' only. Find the sum of flexibilities of all possible pairs of strings (c', d') such that c' and d' can be obtained from c and d respectively by replacing the question marks with either 'A' or 'B', modulo 109 + 7.

The first line contains the string c (1 ≤ |c| ≤ 3·105). The second line contains the string d (1 ≤ |d| ≤ 3·105). The last line contains a single integer n (1 ≤ n ≤ 3·105).

Output a single integer: the answer to the problem, modulo 109 + 7.

NoteFor the first sample, there are four possible pairs of (c', d').If (c', d') = (AA, A), then the flexibility is 0.If (c', d') = (AB, A), then the flexibility is 0.If (c', d') = (AA, B), then the flexibility is 2, as the pairs of binary strings (1, 11), (0, 00) are the only good pairs.If (c', d') = (AB, B), then the flexibility is 0.Thus, the total flexibility is 2.For the second sample, there are 21 + 22 + ... + 210 = 2046 possible binary strings of length not greater 10, and the set of pairs of good strings is precisely the set of pairs (s, s), where s is a binary string of length not greater than 10.


$$$k$$$ people want to split $$$n$$$ candies between them. Each candy should be given to exactly one of them or be thrown away.The people are numbered from $$$1$$$ to $$$k$$$, and Arkady is the first of them. To split the candies, Arkady will choose an integer $$$x$$$ and then give the first $$$x$$$ candies to himself, the next $$$x$$$ candies to the second person, the next $$$x$$$ candies to the third person and so on in a cycle. The leftover (the remainder that is not divisible by $$$x$$$) will be thrown away.Arkady can't choose $$$x$$$ greater than $$$M$$$ as it is considered greedy. Also, he can't choose such a small $$$x$$$ that some person will receive candies more than $$$D$$$ times, as it is considered a slow splitting.Please find what is the maximum number of candies Arkady can receive by choosing some valid $$$x$$$.

The only line contains four integers $$$n$$$, $$$k$$$, $$$M$$$ and $$$D$$$ ($$$2 \le n \le 10^{18}$$$, $$$2 \le k \le n$$$, $$$1 \le M \le n$$$, $$$1 \le D \le \min{(n, 1000)}$$$, $$$M \cdot D \cdot k \ge n$$$) — the number of candies, the number of people, the maximum number of candies given to a person at once, the maximum number of times a person can receive candies.

Print a single integer — the maximum possible number of candies Arkady can give to himself. Note that it is always possible to choose some valid $$$x$$$.

NoteIn the first example Arkady should choose $$$x = 4$$$. He will give $$$4$$$ candies to himself, $$$4$$$ candies to the second person, $$$4$$$ candies to the third person, then $$$4$$$ candies to the fourth person and then again $$$4$$$ candies to himself. No person is given candies more than $$$2$$$ times, and Arkady receives $$$8$$$ candies in total.Note that if Arkady chooses $$$x = 5$$$, he will receive only $$$5$$$ candies, and if he chooses $$$x = 3$$$, he will receive only $$$3 + 3 = 6$$$ candies as well as the second person, the third and the fourth persons will receive $$$3$$$ candies, and $$$2$$$ candies will be thrown away. He can't choose $$$x = 1$$$ nor $$$x = 2$$$ because in these cases he will receive candies more than $$$2$$$ times.In the second example Arkady has to choose $$$x = 4$$$, because any smaller value leads to him receiving candies more than $$$1$$$ time.


Your task is the exact same as for the easy version. But this time, the marmots subtract the village's population P from their random number before responding to Heidi's request.Also, there are now villages with as few as a single inhabitant, meaning that .Can you help Heidi find out whether a village follows a Poisson or a uniform distribution?

Same as for the easy and medium versions. But remember that now 1 ≤ P ≤ 1000 and that the marmots may provide positive as well as negative integers.

Output one line per village, in the same order as provided in the input. The village's line shall state poisson if the village's distribution is of the Poisson type, and uniform if the answers came from a uniform distribution.


Two chess pieces, a rook and a knight, stand on a standard chessboard 8 × 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.Your task is to find the number of ways to place another knight on the board so that none of the three pieces on the board beat another one. A new piece can only be placed on an empty square.

The first input line contains the description of the rook's position on the board. This description is a line which is 2 in length. Its first symbol is a lower-case Latin letter from a to h, and its second symbol is a number from 1 to 8. The second line contains the description of the knight's position in a similar way. It is guaranteed that their positions do not coincide.

Print a single number which is the required number of ways.


As you all know, the plum harvesting season is on! Little Milutin had his plums planted in an orchard that can be represented as an $$$n$$$ by $$$m$$$ matrix. While he was harvesting, he wrote the heights of all trees in a matrix of dimensions $$$n$$$ by $$$m$$$.At night, when he has spare time, he likes to perform various statistics on his trees. This time, he is curious to find out the height of his lowest tree. So far, he has discovered some interesting properties of his orchard. There is one particular property that he thinks is useful for finding the tree with the smallest heigh.Formally, let $$$L(i)$$$ be the leftmost tree with the smallest height in the $$$i$$$-th row of his orchard. He knows that $$$L(i) \le L(i+1)$$$ for all $$$1 \le i \le n - 1$$$. Moreover, if he takes a submatrix induced by any subset of rows and any subset of columns, $$$L(i) \le L(i+1)$$$ will hold for all $$$1 \le i \le n'-1$$$, where $$$n'$$$ is the number of rows in that submatrix.Since the season is at its peak and he is short on time, he asks you to help him find the plum tree with minimal height.

This problem is interactive. The first line of input will contain two integers $$$n$$$ and $$$m$$$, representing the number of rows and the number of columns in Milutin's orchard. It is guaranteed that $$$1 \le n, m \le 10^6$$$. The following lines will contain the answers to your queries.

Once you know have found the minimum value $$$r$$$, you should print ! $$$r$$$ to the standard output.


Qwerty the Ranger arrived to the Diatar system with a very important task. He should deliver a special carcinogen for scientific research to planet Persephone. This is urgent, so Qwerty has to get to the planet as soon as possible. A lost day may fail negotiations as nobody is going to pay for an overdue carcinogen.You can consider Qwerty's ship, the planet Persephone and the star Diatar points on a plane. Diatar is located in the origin of coordinate axes — at point (0, 0). Persephone goes round Diatar along a circular orbit with radius R in the counter-clockwise direction at constant linear speed vp (thus, for instance, a full circle around the star takes  of time). At the initial moment of time Persephone is located at point (xp, yp).At the initial moment of time Qwerty's ship is at point (x, y). Qwerty can move in any direction at speed of at most v (v > vp). The star Diatar is hot (as all stars), so Qwerty can't get too close to it. The ship's metal sheathing melts at distance r (r < R) from the star.Find the minimum time Qwerty needs to get the carcinogen to planet Persephone.

The first line contains space-separated integers xp, yp and vp ( - 104 ≤ xp, yp ≤ 104, 1 ≤ vp < 104) — Persephone's initial position and the speed at which it goes round Diatar. The second line contains space-separated integers x, y, v and r ( - 104 ≤ x, y ≤ 104, 1 < v ≤ 104, 1 ≤ r ≤ 104) — The intial position of Qwerty's ship, its maximum speed and the minimum safe distance to star Diatar. It is guaranteed that r2 < x2 + y2, r2 < xp2 + yp2 and vp < v.

Print a single real number — the minimum possible delivery time. The answer will be considered valid if its absolute or relative error does not exceed 10 - 6.


Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.But I also don't want to use many numbers, so I'll choose three positive integers (they don't have to be distinct) which are not greater than n. Can you help me to find the maximum possible least common multiple of these three integers?

The first line contains an integer n (1 ≤ n ≤ 106) — the n mentioned in the statement.

Print a single integer — the maximum possible LCM of three not necessarily distinct positive integers that are not greater than n.

NoteThe least common multiple of some positive integers is the least positive integer which is multiple for each of them.The result may become very large, 32-bit integer won't be enough. So using 64-bit integers is recommended.For the last example, we can chose numbers 7, 6, 5 and the LCM of them is 7·6·5 = 210. It is the maximum value we can get.


Consider the following grammar: <expression> ::= <term> | <expression> '+' <term> <term> ::= <number> | <number> '-' <number> | <number> '(' <expression> ')' <number> ::= <pos_digit> | <number> <digit> <digit> ::= '0' | <pos_digit> <pos_digit> ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'This grammar describes a number in decimal system using the following rules: <number> describes itself, <number>-<number> (l-r, l ≤ r) describes integer which is concatenation of all integers from l to r, written without leading zeros. For example, 8-11 describes 891011, <number>(<expression>) describes integer which is concatenation of <number> copies of integer described by <expression>, <expression>+<term> describes integer which is concatenation of integers described by <expression> and <term>.For example, 2(2-4+1)+2(2(17)) describes the integer 2341234117171717.You are given an expression in the given grammar. Print the integer described by it modulo 109 + 7.

The only line contains a non-empty string at most 105 characters long which is valid according to the given grammar. In particular, it means that in terms l-r l ≤ r holds.

Print single integer — the number described by the expression modulo 109 + 7.


Vasya has got a tree consisting of $$$n$$$ vertices. He wants to delete some (possibly zero) edges in this tree such that the maximum matching in the resulting graph is unique. He asks you to calculate the number of ways to choose a set of edges to remove.A matching in the graph is a subset of its edges such that there is no vertex incident to two (or more) edges from the subset. A maximum matching is a matching such that the number of edges in the subset is maximum possible among all matchings in this graph.Since the answer may be large, output it modulo $$$998244353$$$.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the number of vertices in the tree. Each of the next $$$n − 1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1 \le u, v \le n, u \neq v$$$) denoting an edge between vertex $$$u$$$ and vertex $$$v$$$. It is guaranteed that these edges form a tree.

Print one integer — the number of ways to delete some (possibly empty) subset of edges so that the maximum matching in the resulting graph is unique. Print the answer modulo $$$998244353$$$.

NotePossible ways to delete edges in the first example:   delete $$$(1, 2)$$$ and $$$(1, 3)$$$.  delete $$$(1, 2)$$$ and $$$(1, 4)$$$.  delete $$$(1, 3)$$$ and $$$(1, 4)$$$.  delete all edges. Possible ways to delete edges in the second example:   delete no edges.  delete $$$(1, 2)$$$ and $$$(2, 3)$$$.  delete $$$(1, 2)$$$ and $$$(3, 4)$$$.  delete $$$(2, 3)$$$ and $$$(3, 4)$$$.  delete $$$(2, 3)$$$.  delete all edges.


Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 = 6 cubes, and so on. Thus, the i-th level of the pyramid must have 1 + 2 + ... + (i - 1) + i cubes.Vanya wants to know what is the maximum height of the pyramid that he can make using the given cubes.

The first line contains integer n (1 ≤ n ≤ 104) — the number of cubes given to Vanya.

Print the maximum possible height of the pyramid in the single line.


InputThe input contains two integers a1, a2 (0 ≤ ai ≤ 109), separated by a single space.OutputOutput a single integer.ExamplesInput3 14Output44Input27 12Output48Input100 200Output102


You're given a row with $$$n$$$ chairs. We call a seating of people "maximal" if the two following conditions hold:  There are no neighbors adjacent to anyone seated.  It's impossible to seat one more person without violating the first rule. The seating is given as a string consisting of zeros and ones ($$$0$$$ means that the corresponding seat is empty, $$$1$$$ — occupied). The goal is to determine whether this seating is "maximal".Note that the first and last seats are not adjacent (if $$$n \ne 2$$$).

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 1000$$$) — the number of chairs. The next line contains a string of $$$n$$$ characters, each of them is either zero or one, describing the seating.

Output "Yes" (without quotation marks) if the seating is "maximal". Otherwise print "No". You are allowed to print letters in whatever case you'd like (uppercase or lowercase).

NoteIn sample case one the given seating is maximal.In sample case two the person at chair three has a neighbour to the right.In sample case three it is possible to seat yet another person into chair three.


The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis. Aki is fond of numbers, especially those with trailing zeros. For example, the number $$$9200$$$ has two trailing zeros. Aki thinks the more trailing zero digits a number has, the prettier it is.However, Aki believes, that the number of trailing zeros of a number is not static, but depends on the base (radix) it is represented in. Thus, he considers a few scenarios with some numbers and bases. And now, since the numbers he used become quite bizarre, he asks you to help him to calculate the beauty of these numbers.Given two integers $$$n$$$ and $$$b$$$ (in decimal notation), your task is to calculate the number of trailing zero digits in the $$$b$$$-ary (in the base/radix of $$$b$$$) representation of $$$n\,!$$$ (factorial of $$$n$$$).

The only line of the input contains two integers $$$n$$$ and $$$b$$$ ($$$1 \le n \le 10^{18}$$$, $$$2 \le b \le 10^{12}$$$).

Print an only integer — the number of trailing zero digits in the $$$b$$$-ary representation of $$$n!$$$

NoteIn the first example, $$$6!_{(10)} = 720_{(10)} = 880_{(9)}$$$.In the third and fourth example, $$$5!_{(10)} = 120_{(10)} = 1111000_{(2)}$$$.The representation of the number $$$x$$$ in the $$$b$$$-ary base is $$$d_1, d_2, \ldots, d_k$$$ if $$$x = d_1 b^{k - 1} + d_2 b^{k - 2} + \ldots + d_k b^0$$$, where $$$d_i$$$ are integers and $$$0 \le d_i \le b - 1$$$. For example, the number $$$720$$$ from the first example is represented as $$$880_{(9)}$$$ since $$$720 = 8 \cdot 9^2 + 8 \cdot 9 + 0 \cdot 1$$$.You can read more about bases here.


Mislove had an array $$$a_1$$$, $$$a_2$$$, $$$\cdots$$$, $$$a_n$$$ of $$$n$$$ positive integers, but he has lost it. He only remembers the following facts about it: The number of different numbers in the array is not less than $$$l$$$ and is not greater than $$$r$$$; For each array's element $$$a_i$$$ either $$$a_i = 1$$$ or $$$a_i$$$ is even and there is a number $$$\dfrac{a_i}{2}$$$ in the array.For example, if $$$n=5$$$, $$$l=2$$$, $$$r=3$$$ then an array could be $$$[1,2,2,4,4]$$$ or $$$[1,1,1,1,2]$$$; but it couldn't be $$$[1,2,2,4,8]$$$ because this array contains $$$4$$$ different numbers; it couldn't be $$$[1,2,2,3,3]$$$ because $$$3$$$ is odd and isn't equal to $$$1$$$; and it couldn't be $$$[1,1,2,2,16]$$$ because there is a number $$$16$$$ in the array but there isn't a number $$$\frac{16}{2} = 8$$$.According to these facts, he is asking you to count the minimal and the maximal possible sums of all elements in an array.

The only input line contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$1 \leq n \leq 1\,000$$$, $$$1 \leq l \leq r \leq \min(n, 20)$$$) — an array's size, the minimal number and the maximal number of distinct elements in an array.

Output two numbers — the minimal and the maximal possible sums of all elements in an array.

NoteIn the first example, an array could be the one of the following: $$$[1,1,1,2]$$$, $$$[1,1,2,2]$$$ or $$$[1,2,2,2]$$$. In the first case the minimal sum is reached and in the last case the maximal sum is reached.In the second example, the minimal sum is reached at the array $$$[1,1,1,1,1]$$$, and the maximal one is reached at the array $$$[1,2,4,8,16]$$$.


InputThe input contains a single integer a (1 ≤ a ≤ 64).OutputOutput a single integer.ExamplesInput2Output1Input4Output2Input27Output5Input42Output6


In the wilds far beyond lies the Land of Sacredness, which can be viewed as a tree  — connected undirected graph consisting of $$$n$$$ nodes and $$$n-1$$$ edges. The nodes are numbered from $$$1$$$ to $$$n$$$. There are $$$m$$$ travelers attracted by its prosperity and beauty. Thereupon, they set off their journey on this land. The $$$i$$$-th traveler will travel along the shortest path from $$$s_i$$$ to $$$t_i$$$. In doing so, they will go through all edges in the shortest path from $$$s_i$$$ to $$$t_i$$$, which is unique in the tree.During their journey, the travelers will acquaint themselves with the others. Some may even become friends. To be specific, the $$$i$$$-th traveler and the $$$j$$$-th traveler will become friends if and only if there are at least $$$k$$$ edges that both the $$$i$$$-th traveler and the $$$j$$$-th traveler will go through. Your task is to find out the number of pairs of travelers $$$(i, j)$$$ satisfying the following conditions:   $$$1 \leq i < j \leq m$$$.  the $$$i$$$-th traveler and the $$$j$$$-th traveler will become friends.

The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2 \le n, m \le 1.5 \cdot 10^5$$$, $$$1\le k\le n$$$).  Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$), denoting there is an edge between $$$u$$$ and $$$v$$$.  The $$$i$$$-th line of the next $$$m$$$ lines contains two integers $$$s_i$$$ and $$$t_i$$$ ($$$1\le s_i,t_i\le n$$$, $$$s_i \neq t_i$$$), denoting the starting point and the destination of $$$i$$$-th traveler.  It is guaranteed that the given edges form a tree.

The only line contains a single integer  — the number of pairs of travelers satisfying the given conditions.

NoteIn the first example there are $$$4$$$ pairs satisfying the given requirements: $$$(1,2)$$$, $$$(1,3)$$$, $$$(1,4)$$$, $$$(3,4)$$$. The $$$1$$$-st traveler and the $$$2$$$-nd traveler both go through the edge $$$6-8$$$.  The $$$1$$$-st traveler and the $$$3$$$-rd traveler both go through the edge $$$2-6$$$.  The $$$1$$$-st traveler and the $$$4$$$-th traveler both go through the edge $$$1-2$$$ and $$$2-6$$$.  The $$$3$$$-rd traveler and the $$$4$$$-th traveler both go through the edge $$$2-6$$$.


per nextum in unam tum XI conscribementis fac sic    vestibulo perlegementum da varo.    morde varo.    seqis cumula varum.cisper nextum in unam tum XI conscribementis fac sic    seqis decumulamenta da varo.    varum privamentum fodementum da aresulto.    varum tum III elevamentum tum V multiplicamentum da bresulto.    aresultum tum bresultum addementum da resulto.    si CD tum resultum non praestantiam fac sic        dictum sic f(%d) = %.2f cis tum varum tum resultum egresso describe.        novumversum egresso scribe.    cis    si CD tum resultum praestantiam fac sic        dictum sic f(%d) = MAGNA NIMIS! cis tum varum egresso describe.        novumversum egresso scribe.            ciscis

The input consists of several integers, one per line. Each integer is between -50 and 50, inclusive.


Alex enjoys performing magic tricks. He has a trick that requires a deck of n cards. He has m identical decks of n different cards each, which have been mixed together. When Alex wishes to perform the trick, he grabs n cards at random and performs the trick with those. The resulting deck looks like a normal deck, but may have duplicates of some cards.The trick itself is performed as follows: first Alex allows you to choose a random card from the deck. You memorize the card and put it back in the deck. Then Alex shuffles the deck, and pulls out a card. If the card matches the one you memorized, the trick is successful.You don't think Alex is a very good magician, and that he just pulls a card randomly from the deck. Determine the probability of the trick being successful if this is the case.

First line of the input consists of two integers n and m (1 ≤ n, m ≤ 1000), separated by space — number of cards in each deck, and number of decks.

On the only line of the output print one floating point number – probability of Alex successfully performing the trick. Relative or absolute error of your answer should not be higher than 10 - 6.

NoteIn the first sample, with probability  Alex will perform the trick with two cards with the same value from two different decks. In this case the trick is guaranteed to succeed.With the remaining  probability he took two different cards, and the probability of pulling off the trick is .The resulting probability is


You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.

The single line of the input contains a pair of integers m, s (1 ≤ m ≤ 100, 0 ≤ s ≤ 900) — the length and the sum of the digits of the required numbers.

In the output print the pair of the required non-negative integer numbers — first the minimum possible number, then — the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).


At the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According to the results, each student got some score from 1 to m points. We know that c1 schoolchildren got 1 point, c2 children got 2 points, ..., cm children got m points. Now you need to set the passing rate k (integer from 1 to m): all schoolchildren who got less than k points go to the beginner group and those who get at strictly least k points go to the intermediate group. We know that if the size of a group is more than y, then the university won't find a room for them. We also know that if a group has less than x schoolchildren, then it is too small and there's no point in having classes with it. So, you need to split all schoolchildren into two groups so that the size of each group was from x to y, inclusive. Help the university pick the passing rate in a way that meets these requirements.

The first line contains integer m (2 ≤ m ≤ 100). The second line contains m integers c1, c2, ..., cm, separated by single spaces (0 ≤ ci ≤ 100). The third line contains two space-separated integers x and y (1 ≤ x ≤ y ≤ 10000). At least one ci is greater than 0.

If it is impossible to pick a passing rate in a way that makes the size of each resulting groups at least x and at most y, print 0. Otherwise, print an integer from 1 to m — the passing rate you'd like to suggest. If there are multiple possible answers, print any of them.

NoteIn the first sample the beginner group has 7 students, the intermediate group has 6 of them. In the second sample another correct answer is 3.


You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code.

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10$$$) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints. The next line contains $$$n$$$ distinct space-separated integers $$$x_1, x_2, \ldots, x_n$$$ ($$$0 \le x_i \le 9$$$) representing the sequence. The next line contains $$$m$$$ distinct space-separated integers $$$y_1, y_2, \ldots, y_m$$$ ($$$0 \le y_i \le 9$$$) — the keys with fingerprints.

In a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.

NoteIn the first example, the only digits with fingerprints are $$$1$$$, $$$2$$$ and $$$7$$$. All three of them appear in the sequence you know, $$$7$$$ first, then $$$1$$$ and then $$$2$$$. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.In the second example digits $$$0$$$, $$$1$$$, $$$7$$$ and $$$9$$$ have fingerprints, however only $$$0$$$ and $$$1$$$ appear in the original sequence. $$$1$$$ appears earlier, so the output is 1 0. Again, the order is important.


Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors x and y (x ≠ y) meet in a violent fight, then the pixel that survives the fight immediately changes its color to z (z ≠ x; z ≠ y). Pixels of the same color are friends, so they don't fight.The King of Flatland knows that his land will be peaceful and prosperous when the pixels are of the same color. For each of the three colors you know the number of pixels of this color that inhabit Flatland. Help the king and determine whether fights can bring peace and prosperity to the country and if it is possible, find the minimum number of fights needed to make the land peaceful and prosperous.

The first line contains three space-separated integers a, b and c (0 ≤ a, b, c ≤ 231; a + b + c > 0) — the number of red, green and blue pixels, correspondingly.

Print a single number — the minimum number of pixel fights before the country becomes peaceful and prosperous. If making the country peaceful and prosperous is impossible, print -1.

NoteIn the first test sample the country needs only one fight to achieve peace and prosperity. Besides, it can be any fight whatsoever. For example, let's assume that the green and the blue pixels fight, then the surviving pixel will be red. As a result, after the fight there are two red pixels. There won't be other pixels.In the second sample the following sequence of fights is possible: red and blue, green and red, red and blue. As a result, after all fights there is one green pixel left.


After passing a test, Vasya got himself a box of $$$n$$$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.This means the process of eating candies is the following: in the beginning Vasya chooses a single integer $$$k$$$, same for all days. After that, in the morning he eats $$$k$$$ candies from the box (if there are less than $$$k$$$ candies in the box, he eats them all), then in the evening Petya eats $$$10\%$$$ of the candies remaining in the box. If there are still candies left in the box, the process repeats — next day Vasya eats $$$k$$$ candies again, and Petya — $$$10\%$$$ of the candies left in a box, and so on.If the amount of candies in the box is not divisible by $$$10$$$, Petya rounds the amount he takes from the box down. For example, if there were $$$97$$$ candies in the box, Petya would eat only $$$9$$$ of them. In particular, if there are less than $$$10$$$ candies in a box, Petya won't eat any at all.Your task is to find out the minimal amount of $$$k$$$ that can be chosen by Vasya so that he would eat at least half of the $$$n$$$ candies he initially got. Note that the number $$$k$$$ must be integer.

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^{18}$$$) — the initial amount of candies in the box.

Output a single integer — the minimal amount of $$$k$$$ that would allow Vasya to eat at least half of candies he got.

NoteIn the sample, the amount of candies, with $$$k=3$$$, would change in the following way (Vasya eats first):$$$68 \to 65 \to 59 \to 56 \to 51 \to 48 \to 44 \to 41 \\ \to 37 \to 34 \to 31 \to 28 \to 26 \to 23 \to 21 \to 18 \to 17 \to 14 \\ \to 13 \to 10 \to 9 \to 6 \to 6 \to 3 \to 3 \to 0$$$.In total, Vasya would eat $$$39$$$ candies, while Petya — $$$29$$$.


Since next season are coming, you'd like to form a team from two or three participants. There are $$$n$$$ candidates, the $$$i$$$-th candidate has rank $$$a_i$$$. But you have weird requirements for your teammates: if you have rank $$$v$$$ and have chosen the $$$i$$$-th and $$$j$$$-th candidate, then $$$GCD(v, a_i) = X$$$ and $$$LCM(v, a_j) = Y$$$ must be met.You are very experienced, so you can change your rank to any non-negative integer but $$$X$$$ and $$$Y$$$ are tied with your birthdate, so they are fixed.Now you want to know, how many are there pairs $$$(i, j)$$$ such that there exists an integer $$$v$$$ meeting the following constraints: $$$GCD(v, a_i) = X$$$ and $$$LCM(v, a_j) = Y$$$. It's possible that $$$i = j$$$ and you form a team of two.$$$GCD$$$ is the greatest common divisor of two number, $$$LCM$$$ — the least common multiple.

First line contains three integers $$$n$$$, $$$X$$$ and $$$Y$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le X \le Y \le 10^{18}$$$) — the number of candidates and corresponding constants. Second line contains $$$n$$$ space separated integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^{18}$$$) — ranks of candidates.

Print the only integer — the number of pairs $$$(i, j)$$$ such that there exists an integer $$$v$$$ meeting the following constraints: $$$GCD(v, a_i) = X$$$ and $$$LCM(v, a_j) = Y$$$. It's possible that $$$i = j$$$.


Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm:  if the last digit of the number is non-zero, she decreases the number by one;  if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number $$$n$$$. Tanya will subtract one from it $$$k$$$ times. Your task is to print the result after all $$$k$$$ subtractions.It is guaranteed that the result will be positive integer number.

The first line of the input contains two integer numbers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le k \le 50$$$) — the number from which Tanya will subtract and the number of subtractions correspondingly.

Print one integer number — the result of the decreasing $$$n$$$ by one $$$k$$$ times. It is guaranteed that the result will be positive integer number.

NoteThe first example corresponds to the following sequence: $$$512 \rightarrow 511 \rightarrow 510 \rightarrow 51 \rightarrow 50$$$.


You are given a complete bipartite graph with $$$2n$$$ nodes, with $$$n$$$ nodes on each side of the bipartition. Nodes $$$1$$$ through $$$n$$$ are on one side of the bipartition, and nodes $$$n+1$$$ to $$$2n$$$ are on the other side. You are also given an $$$n \times n$$$ matrix $$$a$$$ describing the edge weights. $$$a_{ij}$$$ denotes the weight of the edge between nodes $$$i$$$ and $$$j+n$$$. Each edge has a distinct weight.Alice and Bob are playing a game on this graph. First Alice chooses to play as either "increasing" or "decreasing" for herself, and Bob gets the other choice. Then she places a token on any node of the graph. Bob then moves the token along any edge incident to that node. They now take turns playing the following game, with Alice going first.The current player must move the token from the current vertex to some adjacent unvisited vertex. Let $$$w$$$ be the last weight of the last edge that was traversed. The edge that is traversed must be strictly greater than $$$w$$$ if the player is playing as "increasing", otherwise, it must be strictly less. The first player unable to make a move loses.You are given $$$n$$$ and the edge weights of the graph. You can choose to play as either Alice or Bob, and you will play against the judge. You must win all the games for your answer to be judged correct.

NoteThe first example has two test cases. In the first test case, the graph looks like the following.  In the sample output, the player decides to play as Alice and chooses "decreasing" and starting at node $$$3$$$. The judge responds by moving to node $$$6$$$. After, the player moves to node $$$2$$$. At this point, the judge has no more moves (since the weight must "increase"), so it gives up and prints $$$-1$$$.In the next case, we have two nodes connected by an edge of weight $$$1$$$. The player decides to play as Bob. No matter what the judge chooses, the player can move the token to the other node and the judge has no moves so will lose.


Consider a billiard table of rectangular size $$$n \times m$$$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture).   There is one ball at the point $$$(x, y)$$$ currently. Max comes to the table and strikes the ball. The ball starts moving along a line that is parallel to one of the axes or that makes a $$$45^{\circ}$$$ angle with them. We will assume that:   the angles between the directions of the ball before and after a collision with a side are equal,  the ball moves indefinitely long, it only stops when it falls into a pocket,  the ball can be considered as a point, it falls into a pocket if and only if its coordinates coincide with one of the pockets,  initially the ball is not in a pocket. Note that the ball can move along some side, in this case the ball will just fall into the pocket at the end of the side.Your task is to determine whether the ball will fall into a pocket eventually, and if yes, which of the four pockets it will be.

The only line contains $$$6$$$ integers $$$n$$$, $$$m$$$, $$$x$$$, $$$y$$$, $$$v_x$$$, $$$v_y$$$ ($$$1 \leq n, m \leq 10^9$$$, $$$0 \leq x \leq n$$$; $$$0 \leq y \leq m$$$; $$$-1 \leq v_x, v_y \leq 1$$$; $$$(v_x, v_y) \neq (0, 0)$$$) — the width of the table, the length of the table, the $$$x$$$-coordinate of the initial position of the ball, the $$$y$$$-coordinate of the initial position of the ball, the $$$x$$$-component of its initial speed and the $$$y$$$-component of its initial speed, respectively. It is guaranteed that the ball is not initially in a pocket.

Print the coordinates of the pocket the ball will fall into, or $$$-1$$$ if the ball will move indefinitely.

NoteThe first sample:   The second sample:   In the third sample the ball will never change its $$$y$$$ coordinate, so the ball will never fall into a pocket.


Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as depicted in the figure below.  The dimension of this tile is perfect for this kitchen, as he will need exactly $$$w \times h$$$ tiles without any scraps. That is, the width of the kitchen is $$$w$$$ tiles, and the height is $$$h$$$ tiles. As each tile can be rotated in one of four ways, he still needs to decide on how exactly he will tile the floor. There is a single aesthetic criterion that he wants to fulfil: two adjacent tiles must not share a colour on the edge — i.e. one of the tiles must have a white colour on the shared border, and the second one must be black.    The picture on the left shows one valid tiling of a $$$3 \times 2$$$ kitchen. The picture on the right shows an invalid arrangement, as the bottom two tiles touch with their white parts. Find the number of possible tilings. As this number may be large, output its remainder when divided by $$$998244353$$$ (a prime number).

The only line contains two space separated integers $$$w$$$, $$$h$$$ ($$$1 \leq w,h \leq 1\,000$$$) — the width and height of the kitchen, measured in tiles.

Output a single integer $$$n$$$ — the remainder of the number of tilings when divided by $$$998244353$$$.


To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friendship relations, and not to invite those who dislike each other. Both friendship and dislike are mutual feelings.More formally, for each invited person the following conditions should be fulfilled:   all his friends should also be invited to the party;  the party shouldn't have any people he dislikes;  all people who are invited to the party should be connected with him by friendship either directly or through a chain of common friends of arbitrary length. We'll say that people a1 and ap are connected through a chain of common friends if there exists a sequence of people a2, a3, ..., ap - 1 such that all pairs of people ai and ai + 1 (1 ≤ i < p) are friends. Help the Beaver find the maximum number of acquaintances he can invite.

The first line of input contains an integer n — the number of the Beaver's acquaintances.  The second line contains an integer k  — the number of pairs of friends. Next k lines contain space-separated pairs of integers ui, vi  — indices of people who form the i-th pair of friends. The next line contains an integer m  — the number of pairs of people who dislike each other. Next m lines describe pairs of people who dislike each other in the same format as the pairs of friends were described. Each pair of people is mentioned in the input at most once . In particular, two persons cannot be friends and dislike each other at the same time. The input limitations for getting 30 points are:    2 ≤ n ≤ 14  The input limitations for getting 100 points are:    2 ≤ n ≤ 2000

Output a single number — the maximum number of people that can be invited to the party. If a group of people that meets all the requirements is impossible to select, output 0.

NoteLet's have a look at the example.   Two groups of people can be invited: {1, 2, 3} and {4, 5}, thus the answer will be the size of the largest of these groups. Group {6, 7, 8, 9} doesn't fit, since it includes people 7 and 9 who dislike each other. Group {1, 2, 3, 4, 5} also doesn't fit, because not all of its members are connected by a chain of common friends (for example, people 2 and 5 aren't connected).


Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards" and one will point "downwards". After another year, each triangle plant divides into four triangle plants: three of them will be directed in the same direction as the parent plant, and one of them will be directed in the opposite direction. Then each year the process repeats. The figure below illustrates this process.  Help the dwarfs find out how many triangle plants that point "upwards" will be in n years.

The first line contains a single integer n (0 ≤ n ≤ 1018) — the number of full years when the plant grew. Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

Print a single integer — the remainder of dividing the number of plants that will point "upwards" in n years by 1000000007 (109 + 7).

NoteThe first test sample corresponds to the second triangle on the figure in the statement. The second test sample corresponds to the third one.


It's New Year's Eve soon, so Ivan decided it's high time he started setting the table. Ivan has bought two cakes and cut them into pieces: the first cake has been cut into a pieces, and the second one — into b pieces.Ivan knows that there will be n people at the celebration (including himself), so Ivan has set n plates for the cakes. Now he is thinking about how to distribute the cakes between the plates. Ivan wants to do it in such a way that all following conditions are met:  Each piece of each cake is put on some plate;  Each plate contains at least one piece of cake;  No plate contains pieces of both cakes. To make his guests happy, Ivan wants to distribute the cakes in such a way that the minimum number of pieces on the plate is maximized. Formally, Ivan wants to know the maximum possible number x such that he can distribute the cakes according to the aforementioned conditions, and each plate will contain at least x pieces of cake.Help Ivan to calculate this number x!

The first line contains three integers n, a and b (1 ≤ a, b ≤ 100, 2 ≤ n ≤ a + b) — the number of plates, the number of pieces of the first cake, and the number of pieces of the second cake, respectively.

Print the maximum possible number x such that Ivan can distribute the cake in such a way that each plate will contain at least x pieces of cake.

NoteIn the first example there is only one way to distribute cakes to plates, all of them will have 1 cake on it.In the second example you can have two plates with 3 and 4 pieces of the first cake and two plates both with 5 pieces of the second cake. Minimal number of pieces is 3.


The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. "Do I give such a hard task?" — the HR manager thought. "Just raise number 5 to the power of n and get last two digits of the number. Yes, of course, n can be rather big, and one cannot find the power using a calculator, but we need people who are able to think, not just follow the instructions."Could you pass the interview in the machine vision company in IT City?

The only line of the input contains a single integer n (2 ≤ n ≤ 2·1018) — the power in which you need to raise number 5.

Output the last two digits of 5n without spaces between them.


Ujan needs some rest from cleaning, so he started playing with infinite sequences. He has two integers $$$n$$$ and $$$k$$$. He creates an infinite sequence $$$s$$$ by repeating the following steps.  Find $$$k$$$ smallest distinct positive integers that are not in $$$s$$$. Let's call them $$$u_{1}, u_{2}, \ldots, u_{k}$$$ from the smallest to the largest.  Append $$$u_{1}, u_{2}, \ldots, u_{k}$$$ and $$$\sum_{i=1}^{k} u_{i}$$$ to $$$s$$$ in this order.  Go back to the first step. Ujan will stop procrastinating when he writes the number $$$n$$$ in the sequence $$$s$$$. Help him find the index of $$$n$$$ in $$$s$$$. In other words, find the integer $$$x$$$ such that $$$s_{x} = n$$$. It's possible to prove that all positive integers are included in $$$s$$$ only once.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{5}$$$), the number of test cases. Each of the following $$$t$$$ lines contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^{18}$$$, $$$2 \le k \le 10^{6}$$$), the number to be found in the sequence $$$s$$$ and the parameter used to create the sequence $$$s$$$.

In each of the $$$t$$$ lines, output the answer for the corresponding test case.


Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.Unfortunately, you didn't manage to get into top 25, but you got into top 500, taking place p.Now the elimination round of 8VC Venture Cup 2017 is being held. It has been announced that the Codecraft-17 T-shirt winners will be chosen as follows. Let s be the number of points of the winner of the elimination round of 8VC Venture Cup 2017. Then the following pseudocode will be executed: i := (s div 50) mod 475repeat 25 times:    i := (i * 96 + 42) mod 475    print (26 + i)Here "div" is the integer division operator, "mod" is the modulo (the remainder of division) operator.As the result of pseudocode execution, 25 integers between 26 and 500, inclusive, will be printed. These will be the numbers of places of the participants who get the Codecraft-17 T-shirts. It is guaranteed that the 25 printed integers will be pairwise distinct for any value of s.You're in the lead of the elimination round of 8VC Venture Cup 2017, having x points. You believe that having at least y points in the current round will be enough for victory.To change your final score, you can make any number of successful and unsuccessful hacks. A successful hack brings you 100 points, an unsuccessful one takes 50 points from you. It's difficult to do successful hacks, though.You want to win the current round and, at the same time, ensure getting a Codecraft-17 T-shirt. What is the smallest number of successful hacks you have to do to achieve that?

The only line contains three integers p, x and y (26 ≤ p ≤ 500; 1 ≤ y ≤ x ≤ 20000) — your place in Codecraft-17, your current score in the elimination round of 8VC Venture Cup 2017, and the smallest number of points you consider sufficient for winning the current round.

Output a single integer — the smallest number of successful hacks you have to do in order to both win the elimination round of 8VC Venture Cup 2017 and ensure getting a Codecraft-17 T-shirt. It's guaranteed that your goal is achievable for any valid input data.

NoteIn the first example, there is no need to do any hacks since 10880 points already bring the T-shirt to the 239-th place of Codecraft-17 (that is, you). In this case, according to the pseudocode, the T-shirts will be given to the participants at the following places: 475 422 84 411 453 210 157 294 146 188 420 367 29 356 398 155 102 239 91 133 365 312 449 301 343In the second example, you have to do two successful and one unsuccessful hack to make your score equal to 7408.In the third example, you need to do as many as 24 successful hacks to make your score equal to 10400.In the fourth example, it's sufficient to do 6 unsuccessful hacks (and no successful ones) to make your score equal to 6500, which is just enough for winning the current round and also getting the T-shirt.


"Multidimensional spaces are completely out of style these days, unlike genetics problems" — thought physicist Woll and changed his subject of study to bioinformatics. Analysing results of sequencing he faced the following problem concerning DNA sequences. We will further think of a DNA sequence as an arbitrary string of uppercase letters "A", "C", "G" and "T" (of course, this is a simplified interpretation).Let w be a long DNA sequence and s1, s2, ..., sm — collection of short DNA sequences. Let us say that the collection filters w iff w can be covered with the sequences from the collection. Certainly, substrings corresponding to the different positions of the string may intersect or even cover each other. More formally: denote by |w| the length of w, let symbols of w be numbered from 1 to |w|. Then for each position i in w there exist pair of indices l, r (1 ≤ l ≤ i ≤ r ≤ |w|) such that the substring w[l ... r] equals one of the elements s1, s2, ..., sm of the collection.Woll wants to calculate the number of DNA sequences of a given length filtered by a given collection, but he doesn't know how to deal with it. Help him! Your task is to find the number of different DNA sequences of length n filtered by the collection {si}.Answer may appear very large, so output it modulo 1000000009.

First line contains two integer numbers n and m (1 ≤ n ≤ 1000, 1 ≤ m ≤ 10) — the length of the string and the number of sequences in the collection correspondently.  Next m lines contain the collection sequences si, one per line. Each si is a nonempty string of length not greater than 10. All the strings consist of uppercase letters "A", "C", "G", "T". The collection may contain identical strings.

Output should contain a single integer — the number of strings filtered by the collection modulo 1000000009 (109 + 9).

NoteIn the first sample, a string has to be filtered by "A". Clearly, there is only one such string: "AA".In the second sample, there exist exactly two different strings satisfying the condition (see the pictures below).


You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.You are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sections. On the other hand, you are against putting more than v nuts into some section of the box. What is the minimum number of boxes you have to use if you want to put all the nuts in boxes, and you have b divisors?Please note that you need to minimize the number of used boxes, not sections. You do not have to minimize the number of used divisors.

The first line contains four space-separated integers k, a, b, v (2 ≤ k ≤ 1000; 1 ≤ a, b, v ≤ 1000) — the maximum number of sections in the box, the number of nuts, the number of divisors and the capacity of each section of the box.

Print a single integer — the answer to the problem.

NoteIn the first sample you can act like this:   Put two divisors to the first box. Now the first box has three sections and we can put three nuts into each section. Overall, the first box will have nine nuts.  Do not put any divisors into the second box. Thus, the second box has one section for the last nut. In the end we've put all the ten nuts into boxes.The second sample is different as we have exactly one divisor and we put it to the first box. The next two boxes will have one section each.


You are given a special connected undirected graph where each vertex belongs to at most one simple cycle.Your task is to remove as many edges as needed to convert this graph into a tree (connected graph with no cycles). For each node, independently, output the maximum distance between it and a leaf in the resulting tree, assuming you were to remove the edges in a way that minimizes this distance.

The first line of input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 5\cdot 10^5$$$), the number of nodes and the number of edges, respectively. Each of the following $$$m$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u,v \leq n$$$, $$$u \ne v$$$), and represents an edge connecting the two nodes $$$u$$$ and $$$v$$$. Each pair of nodes is connected by at most one edge. It is guaranteed that the given graph is connected and each vertex belongs to at most one simple cycle.

Print $$$n$$$ space-separated integers, the $$$i$$$-th integer represents the maximum distance between node $$$i$$$ and a leaf if the removed edges were chosen in a way that minimizes this distance.

NoteIn the first sample, a possible way to minimize the maximum distance from vertex $$$1$$$ is by removing the marked edges in the following image:  Note that to minimize the answer for different nodes, you can remove different edges.


A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.Given an array $$$a$$$ of length $$$n$$$, consisting only of the numbers $$$0$$$ and $$$1$$$, and the number $$$k$$$. Exactly $$$k$$$ times the following happens:   Two numbers $$$i$$$ and $$$j$$$ are chosen equiprobable such that ($$$1 \leq i < j \leq n$$$).  The numbers in the $$$i$$$ and $$$j$$$ positions are swapped. Sonya's task is to find the probability that after all the operations are completed, the $$$a$$$ array will be sorted in non-decreasing order. She turned to you for help. Help Sonya solve this problem.It can be shown that the desired probability is either $$$0$$$ or it can be represented as $$$\dfrac{P}{Q}$$$, where $$$P$$$ and $$$Q$$$ are coprime integers and $$$Q \not\equiv 0~\pmod {10^9+7}$$$.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \leq n \leq 100, 1 \leq k \leq 10^9$$$) — the length of the array $$$a$$$ and the number of operations. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 1$$$) — the description of the array $$$a$$$.

If the desired probability is $$$0$$$, print $$$0$$$, otherwise print the value $$$P \cdot Q^{-1}$$$ $$$\pmod {10^9+7}$$$, where $$$P$$$ and $$$Q$$$ are defined above.

NoteIn the first example, all possible variants of the final array $$$a$$$, after applying exactly two operations: $$$(0, 1, 0)$$$, $$$(0, 0, 1)$$$, $$$(1, 0, 0)$$$, $$$(1, 0, 0)$$$, $$$(0, 1, 0)$$$, $$$(0, 0, 1)$$$, $$$(0, 0, 1)$$$, $$$(1, 0, 0)$$$, $$$(0, 1, 0)$$$. Therefore, the answer is $$$\dfrac{3}{9}=\dfrac{1}{3}$$$.In the second example, the array will not be sorted in non-decreasing order after one operation, therefore the answer is $$$0$$$.