A famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch decided to put an end to this tradition and to introduce a new attitude to chessboards.As before, the chessboard is a square-checkered board with the squares arranged in a 8 × 8 grid, each square is painted black or white. Kalevitch suggests that chessboards should be painted in the following manner: there should be chosen a horizontal or a vertical line of 8 squares (i.e. a row or a column), and painted black. Initially the whole chessboard is white, and it can be painted in the above described way one or more times. It is allowed to paint a square many times, but after the first time it does not change its colour any more and remains black. Kalevitch paints chessboards neatly, and it is impossible to judge by an individual square if it was painted with a vertical or a horizontal stroke.Kalevitch hopes that such chessboards will gain popularity, and he will be commissioned to paint chessboards, which will help him ensure a comfortable old age. The clients will inform him what chessboard they want to have, and the painter will paint a white chessboard meeting the client's requirements.It goes without saying that in such business one should economize on everything — for each commission he wants to know the minimum amount of strokes that he has to paint to fulfill the client's needs. You are asked to help Kalevitch with this task.

The input file contains 8 lines, each of the lines contains 8 characters. The given matrix describes the client's requirements, W character stands for a white square, and B character — for a square painted black. It is guaranteed that client's requirments can be fulfilled with a sequence of allowed strokes (vertical/column or horizontal/row).

Output the only number — the minimum amount of rows and columns that Kalevitch has to paint on the white chessboard to meet the client's requirements.

WWWBWWBW
BBBBBBBB
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW

WWWWWWWW
BBBBBBBB
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW


John Doe has an n × m table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size n × n have exactly k points.John Doe wondered, how many distinct ways to fill the table with points are there, provided that the condition must hold. As this number can be rather large, John Doe asks to find its remainder after dividing by 1000000007 (109 + 7).You should assume that John always paints a point exactly in the center of some cell. Two ways to fill a table are considered distinct, if there exists a table cell, that has a point in one way and doesn't have it in the other.

A single line contains space-separated integers n, m, k (1 ≤ n ≤ 100; n ≤ m ≤ 1018; 0 ≤ k ≤ n2) — the number of rows of the table, the number of columns of the table and the number of points each square must contain. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

In a single line print a single integer — the remainder from dividing the described number of ways by 1000000007 (109 + 7).

NoteLet's consider the first test case:      The gray area belongs to both 5 × 5 squares. So, if it has one point, then there shouldn't be points in any other place. If one of the white areas has a point, then the other one also must have a point. Thus, there are about 20 variants, where the point lies in the gray area and 25 variants, where each of the white areas contains a point. Overall there are 45 variants.


A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, "", "(())" and "()()" are regular bracket sequences; "))" and ")((" are bracket sequences (but not regular ones), and "(a)" and "(1)+(1)" are not bracket sequences at all.You have a number of strings; each string is a bracket sequence of length $$$2$$$. So, overall you have $$$cnt_1$$$ strings "((", $$$cnt_2$$$ strings "()", $$$cnt_3$$$ strings ")(" and $$$cnt_4$$$ strings "))". You want to write all these strings in some order, one after another; after that, you will get a long bracket sequence of length $$$2(cnt_1 + cnt_2 + cnt_3 + cnt_4)$$$. You wonder: is it possible to choose some order of the strings you have such that you will get a regular bracket sequence? Note that you may not remove any characters or strings, and you may not add anything either.

The input consists of four lines, $$$i$$$-th of them contains one integer $$$cnt_i$$$ ($$$0 \le cnt_i \le 10^9$$$).

Print one integer: $$$1$$$ if it is possible to form a regular bracket sequence by choosing the correct order of the given strings, $$$0$$$ otherwise.

NoteIn the first example it is possible to construct a string "(())()(()((()()()())))", which is a regular bracket sequence.In the second example it is possible to construct a string "", which is a regular bracket sequence.


Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a problem of his own and call it Noldbach problem. Since Nick is interested only in prime numbers, Noldbach problem states that at least k prime numbers from 2 to n inclusively can be expressed as the sum of three integer numbers: two neighboring prime numbers and 1. For example, 19 = 7 + 11 + 1, or 13 = 5 + 7 + 1.Two prime numbers are called neighboring if there are no other prime numbers between them.You are to help Nick, and find out if he is right or wrong.

The first line of the input contains two integers n (2 ≤ n ≤ 1000) and k (0 ≤ k ≤ 1000).

Output YES if at least k prime numbers from 2 to n inclusively can be expressed as it was described above. Otherwise output NO.

NoteIn the first sample the answer is YES since at least two numbers can be expressed as it was described (for example, 13 and 19). In the second sample the answer is NO since it is impossible to express 7 prime numbers from 2 to 45 in the desired form.


Calculate the number of ways to place $$$n$$$ rooks on $$$n \times n$$$ chessboard so that both following conditions are met:  each empty cell is under attack;  exactly $$$k$$$ pairs of rooks attack each other. An empty cell is under attack if there is at least one rook in the same row or at least one rook in the same column. Two rooks attack each other if they share the same row or column, and there are no other rooks between them. For example, there are only two pairs of rooks that attack each other in the following picture:  One of the ways to place the rooks for $$$n = 3$$$ and $$$k = 2$$$ Two ways to place the rooks are considered different if there exists at least one cell which is empty in one of the ways but contains a rook in another way.The answer might be large, so print it modulo $$$998244353$$$.

The only line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 200000$$$; $$$0 \le k \le \frac{n(n - 1)}{2}$$$).

Print one integer — the number of ways to place the rooks, taken modulo $$$998244353$$$.


The Fat Rat and his friend Сerealguy have had a bet whether at least a few oats are going to descend to them by some clever construction. The figure below shows the clever construction.  A more formal description of the clever construction is as follows. The clever construction consists of n rows with scales. The first row has n scales, the second row has (n - 1) scales, the i-th row has (n - i + 1) scales, the last row has exactly one scale. Let's number the scales in each row from the left to the right, starting from 1. Then the value of wi, k in kilograms (1 ≤ i ≤ n; 1 ≤ k ≤ n - i + 1) is the weight capacity parameter of the k-th scale in the i-th row. If a body whose mass is not less than wi, k falls on the scale with weight capacity wi, k, then the scale breaks. At that anything that the scale has on it, either falls one level down to the left (if possible) or one level down to the right (if possible). In other words, if the scale wi, k (i < n) breaks, then there are at most two possible variants in which the contents of the scale's pan can fall out: all contents of scale wi, k falls either on scale wi + 1, k - 1 (if it exists), or on scale wi + 1, k (if it exists). If scale wn, 1 breaks, then all its contents falls right in the Fat Rat's claws. Please note that the scales that are the first and the last in a row, have only one variant of dropping the contents.Initially, oats are simultaneously put on all scales of the first level. The i-th scale has ai kilograms of oats put on it. After that the scales start breaking and the oats start falling down in some way. You can consider everything to happen instantly. That is, the scale breaks instantly and the oats also fall instantly.The Fat Rat is sure that whatever happens, he will not get the oats from the first level. Cerealguy is sure that there is such a scenario, when the rat gets at least some number of the oats. Help the Fat Rat and the Cerealguy. Determine, which one is right.

The first line contains a single integer n (1 ≤ n ≤ 50) — the number of rows with scales. The next line contains n space-separated integers ai (1 ≤ ai ≤ 106) — the masses of the oats in kilograms. The next n lines contain descriptions of the scales: the i-th line contains (n - i + 1) space-separated integers wi, k (1 ≤ wi, k ≤ 106) — the weight capacity parameters for the scales that stand on the i-th row, in kilograms.

Print "Fat Rat" if the Fat Rat is right, otherwise print "Cerealguy".

NoteNotes to the examples:   The first example: the scale with weight capacity 2 gets 1. That means that the lower scale don't break.  The second sample: all scales in the top row obviously break. Then the oats fall on the lower row. Their total mass is 4,and that's exactly the weight that the lower scale can "nearly endure". So, as 4  ≥  4, the scale breaks.


Once upon a time in the thicket of the mushroom forest lived mushroom gnomes. They were famous among their neighbors for their magic mushrooms. Their magic nature made it possible that between every two neighboring mushrooms every minute grew another mushroom with the weight equal to the sum of weights of two neighboring ones. The mushroom gnomes loved it when everything was in order, that's why they always planted the mushrooms in one line in the order of their weights' increasing. Well... The gnomes planted the mushrooms and went to eat. After x minutes they returned and saw that new mushrooms had grown up, so that the increasing order had been violated. The gnomes replanted all the mushrooms in the correct order, that is, they sorted the mushrooms in the order of the weights' increasing. And went to eat again (those gnomes were quite big eaters). What total weights modulo p will the mushrooms have in another y minutes?

The first line contains four integers n, x, y, p (1 ≤ n ≤ 106, 0 ≤ x, y ≤ 1018, x + y > 0, 2 ≤ p ≤ 109) which represent the number of mushrooms, the number of minutes after the first replanting, the number of minutes after the second replanting and the module. The next line contains n integers ai which represent the mushrooms' weight in the non-decreasing order (0 ≤ ai ≤ 109). Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

The answer should contain a single number which is the total weights of the mushrooms modulo p in the end after x + y minutes.


Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as a guest on somebody else's stadium, the players put on the guest uniform. The only exception to that rule is: when the home uniform color of the host team matches the guests' uniform, the host team puts on its guest uniform as well. For each team the color of the home and guest uniform is different.There are n teams taking part in the national championship. The championship consists of n·(n - 1) games: each team invites each other team to its stadium. At this point Manao wondered: how many times during the championship is a host team going to put on the guest uniform? Note that the order of the games does not affect this number.You know the colors of the home and guest uniform for each team. For simplicity, the colors are numbered by integers in such a way that no two distinct colors have the same number. Help Manao find the answer to his question.

The first line contains an integer n (2 ≤ n ≤ 30). Each of the following n lines contains a pair of distinct space-separated integers hi, ai (1 ≤ hi, ai ≤ 100) — the colors of the i-th team's home and guest uniforms, respectively.

In a single line print the number of games where the host team is going to play in the guest uniform.

NoteIn the first test case the championship consists of 6 games. The only game with the event in question is the game between teams 2 and 1 on the stadium of team 2.In the second test sample the host team will have to wear guest uniform in the games between teams: 1 and 2, 2 and 1, 2 and 3, 3 and 4, 4 and 2 (the host team is written first).


There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given n, print the last digit of 1378n.   Mehrdad has become quite confused and wants you to help him. Please help, although it's a naive cheat.

The single line of input contains one integer n (0  ≤  n  ≤  109).

Print single integer — the last digit of 1378n.

NoteIn the first example, last digit of 13781 = 1378 is 8.In the second example, last digit of 13782 = 1378·1378 = 1898884 is 4.


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.


You are planning to build housing on a street. There are $$$n$$$ spots available on the street on which you can build a house. The spots are labeled from $$$1$$$ to $$$n$$$ from left to right. In each spot, you can build a house with an integer height between $$$0$$$ and $$$h$$$.In each spot, if a house has height $$$a$$$, you will gain $$$a^2$$$ dollars from it.The city has $$$m$$$ zoning restrictions. The $$$i$$$-th restriction says that the tallest house from spots $$$l_i$$$ to $$$r_i$$$ (inclusive) must be at most $$$x_i$$$.You would like to build houses to maximize your profit. Determine the maximum profit possible.

The first line contains three integers $$$n$$$, $$$h$$$, and $$$m$$$ ($$$1 \leq n,h,m \leq 50$$$) — the number of spots, the maximum height, and the number of restrictions. Each of the next $$$m$$$ lines contains three integers $$$l_i$$$, $$$r_i$$$, and $$$x_i$$$ ($$$1 \leq l_i \leq r_i \leq n$$$, $$$0 \leq x_i \leq h$$$) — left and right limits (inclusive) of the $$$i$$$-th restriction and the maximum possible height in that range.

Print a single integer, the maximum profit you can make.

NoteIn the first example, there are $$$3$$$ houses, the maximum height of a house is $$$3$$$, and there are $$$3$$$ restrictions. The first restriction says the tallest house between $$$1$$$ and $$$1$$$ must be at most $$$1$$$. The second restriction says the tallest house between $$$2$$$ and $$$2$$$ must be at most $$$3$$$. The third restriction says the tallest house between $$$3$$$ and $$$3$$$ must be at most $$$2$$$.In this case, it is optimal to build houses with heights $$$[1, 3, 2]$$$. This fits within all the restrictions. The total profit in this case is $$$1^2 + 3^2 + 2^2 = 14$$$.In the second example, there are $$$4$$$ houses, the maximum height of a house is $$$10$$$, and there are $$$2$$$ restrictions. The first restriction says the tallest house from $$$2$$$ to $$$3$$$ must be at most $$$8$$$. The second restriction says the tallest house from $$$3$$$ to $$$4$$$ must be at most $$$7$$$.In this case, it's optimal to build houses with heights $$$[10, 8, 7, 7]$$$. We get a profit of $$$10^2+8^2+7^2+7^2 = 262$$$. Note that there are two restrictions on house $$$3$$$ and both of them must be satisfied. Also, note that even though there isn't any explicit restrictions on house $$$1$$$, we must still limit its height to be at most $$$10$$$ ($$$h=10$$$).


Dima and Anya love playing different games. Now Dima has imagined a new game that he wants to play with Anya.Dima writes n pairs of integers on a piece of paper (li, ri) (1 ≤ li < ri ≤ p). Then players take turns. On his turn the player can do the following actions:  choose the number of the pair i (1 ≤ i ≤ n), such that ri - li > 2;  replace pair number i by pair  or by pair . Notation ⌊x⌋ means rounding down to the closest integer. The player who can't make a move loses.Of course, Dima wants Anya, who will move first, to win. That's why Dima should write out such n pairs of integers (li, ri) (1 ≤ li < ri ≤ p), that if both players play optimally well, the first one wins. Count the number of ways in which Dima can do it. Print the remainder after dividing the answer by number 1000000007 (109 + 7).Two ways are considered distinct, if the ordered sequences of the written pairs are distinct.

The first line contains two integers n, p (1 ≤ n ≤ 1000, 1 ≤ p ≤ 109). The numbers are separated by a single space.

In a single line print the remainder after dividing the answer to the problem by number 1000000007 (109 + 7).


The stardate is 1977 and the science and art of detecting Death Stars is in its infancy. Princess Heidi has received information about the stars in the nearby solar system from the Rebel spies and now, to help her identify the exact location of the Death Star, she needs to know whether this information is correct. Two rebel spies have provided her with the maps of the solar system. Each map is an N × N grid, where each cell is either occupied by a star or empty. To see whether the information is correct, Heidi needs to know whether the two maps are of the same solar system, or if possibly one of the spies is actually an Empire double agent, feeding her false information.Unfortunately, spies may have accidentally rotated a map by 90, 180, or 270 degrees, or flipped it along the vertical or the horizontal axis, before delivering it to Heidi. If Heidi can rotate or flip the maps so that two of them become identical, then those maps are of the same solar system. Otherwise, there are traitors in the Rebel ranks! Help Heidi find out.

The first line of the input contains one number N (1 ≤ N ≤ 10) – the dimension of each map. Next N lines each contain N characters, depicting the first map: 'X' indicates a star, while 'O' indicates an empty quadrant of space. Next N lines each contain N characters, depicting the second map in the same format.

The only line of output should contain the word Yes if the maps are identical, or No if it is impossible to match them by performing rotations and translations.

4
XOOO
XXOO
OOOO
XXXX
XOOO
XOOO
XOXO
XOXX

NoteIn the first test, you can match the first map to the second map by first flipping the first map along the vertical axis, and then by rotating it 90 degrees clockwise.


Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.

The first line contains four integers n1, n2, k1, k2. All numbers in the input are from 1 to 50. This problem doesn't have subproblems. You will get 3 points for the correct submission.

Output "First" if the first player wins and "Second" otherwise.

NoteConsider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely.


Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game? There are n balls put in a row. Each ball is colored in one of k colors. Initially the row doesn't contain three or more contiguous balls with the same color. Iahub has a single ball of color x. He can insert his ball at any position in the row (probably, between two other balls). If at any moment there are three or more contiguous balls of the same color in the row, they are destroyed immediately. This rule is applied multiple times, until there are no more sets of 3 or more contiguous balls of the same color. For example, if Iahub has the row of balls [black, black, white, white, black, black] and a white ball, he can insert the ball between two white balls. Thus three white balls are destroyed, and then four black balls become contiguous, so all four balls are destroyed. The row will not contain any ball in the end, so Iahub can destroy all 6 balls.Iahub wants to destroy as many balls as possible. You are given the description of the row of balls, and the color of Iahub's ball. Help Iahub train for the IOI by telling him the maximum number of balls from the row he can destroy.

The first line of input contains three integers: n (1 ≤ n ≤ 100), k (1 ≤ k ≤ 100) and x (1 ≤ x ≤ k). The next line contains n space-separated integers c1, c2, ..., cn (1 ≤ ci ≤ k). Number ci means that the i-th ball in the row has color ci. It is guaranteed that the initial row of balls will never contain three or more contiguous balls of the same color.

Print a single integer — the maximum number of balls Iahub can destroy.


The only difference between easy and hard versions is constraints.Polycarp loves to listen to music, so he never leaves the player, even on the way home from the university. Polycarp overcomes the distance from the university to the house in exactly $$$T$$$ minutes.In the player, Polycarp stores $$$n$$$ songs, each of which is characterized by two parameters: $$$t_i$$$ and $$$g_i$$$, where $$$t_i$$$ is the length of the song in minutes ($$$1 \le t_i \le 15$$$), $$$g_i$$$ is its genre ($$$1 \le g_i \le 3$$$).Polycarp wants to create such a playlist so that he can listen to music all the time on the way from the university to his home, and at the time of his arrival home, the playlist is over. Polycarp never interrupts songs and always listens to them from beginning to end. Thus, if he started listening to the $$$i$$$-th song, he would spend exactly $$$t_i$$$ minutes on its listening. Polycarp also does not like when two songs of the same genre play in a row (i.e. successively/adjacently) or when the songs in his playlist are repeated.Help Polycarpus count the number of different sequences of songs (their order matters), the total duration is exactly $$$T$$$, such that there are no two consecutive songs of the same genre in them and all the songs in the playlist are different.

The first line of the input contains two integers $$$n$$$ and $$$T$$$ ($$$1 \le n \le 15, 1 \le T \le 225$$$) — the number of songs in the player and the required total duration, respectively. Next, the $$$n$$$ lines contain descriptions of songs: the $$$i$$$-th line contains two integers $$$t_i$$$ and $$$g_i$$$ ($$$1 \le t_i \le 15, 1 \le g_i \le 3$$$) — the duration of the $$$i$$$-th song and its genre, respectively.

Output one integer — the number of different sequences of songs, the total length of exactly $$$T$$$, such that there are no two consecutive songs of the same genre in them and all the songs in the playlist are different. Since the answer may be huge, output it modulo $$$10^9 + 7$$$ (that is, the remainder when dividing the quantity by $$$10^9 + 7$$$).

NoteIn the first example, Polycarp can make any of the $$$6$$$ possible playlist by rearranging the available songs: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]$$$, $$$[3, 1, 2]$$$ and $$$[3, 2, 1]$$$ (indices of the songs are given).In the second example, the first and second songs cannot go in succession (since they have the same genre). Thus, Polycarp can create a playlist in one of $$$2$$$ possible ways: $$$[1, 3, 2]$$$ and $$$[2, 3, 1]$$$ (indices of the songs are given).In the third example, Polycarp can make the following playlists: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]$$$, $$$[3, 1, 2]$$$, $$$[3, 2, 1]$$$, $$$[1, 4]$$$, $$$[4, 1]$$$, $$$[2, 3, 4]$$$ and $$$[4, 3, 2]$$$ (indices of the songs are given).


Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other — noughts). The player who succeeds first in placing three of his marks in a horizontal, vertical or diagonal line wins, and the game is finished. The player who draws crosses goes first. If the grid is filled, but neither Xs, nor 0s form the required line, a draw is announced.You are given a 3 × 3 grid, each grid cell is empty, or occupied by a cross or a nought. You have to find the player (first or second), whose turn is next, or print one of the verdicts below:   illegal — if the given board layout can't appear during a valid game;  the first player won — if in the given board layout the first player has just won;  the second player won — if in the given board layout the second player has just won;  draw — if the given board layout has just let to a draw.

The input consists of three lines, each of the lines contains characters ".", "X" or "0" (a period, a capital letter X, or a digit zero).

Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.


InputThe input contains a single integer $$$a$$$ ($$$0 \le a \le 63$$$).OutputOutput a single number.ExamplesInput
2
Output
2
Input
5
Output
24
Input
35
Output
50


There is a field of size $$$2 \times 2$$$. Each cell of this field can either contain grass or be empty. The value $$$a_{i, j}$$$ is $$$1$$$ if the cell $$$(i, j)$$$ contains grass, or $$$0$$$ otherwise.In one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row $$$x$$$ and the column $$$y$$$, then you cut the grass in all cells $$$a_{x, i}$$$ and all cells $$$a_{i, y}$$$ for all $$$i$$$ from $$$1$$$ to $$$2$$$. After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by $$$0$$$).Your task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all $$$a_{i, j}$$$ zeros).You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 16$$$) — the number of test cases. Then $$$t$$$ test cases follow. The test case consists of two lines, each of these lines contains two integers. The $$$j$$$-th integer in the $$$i$$$-th row is $$$a_{i, j}$$$. If $$$a_{i, j} = 0$$$ then the cell $$$(i, j)$$$ is empty, and if $$$a_{i, j} = 1$$$ the cell $$$(i, j)$$$ contains grass.

For each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all $$$a_{i, j}$$$ zeros) in the corresponding test case.


One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.

The first input line contains the single integer n (1 ≤ n ≤ 1000) — the number of pages in the book. The second line contains seven non-negative space-separated integers that do not exceed 1000 — those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.

Print a single number — the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

NoteNote to the first sample:By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).Note to the second sample:On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.


Each evening after the dinner the SIS's students gather together to play the game of Sport Mafia. For the tournament, Alya puts candies into the box, which will serve as a prize for a winner. To do that, she performs $$$n$$$ actions. The first action performed is to put a single candy into the box. For each of the remaining moves she can choose from two options:  the first option, in case the box contains at least one candy, is to take exactly one candy out and eat it. This way the number of candies in the box decreased by $$$1$$$;  the second option is to put candies in the box. In this case, Alya will put $$$1$$$ more candy, than she put in the previous time. Thus, if the box is empty, then it can only use the second option.For example, one possible sequence of Alya's actions look as follows:  put one candy into the box;  put two candies into the box;  eat one candy from the box;  eat one candy from the box;  put three candies into the box;  eat one candy from the box;  put four candies into the box;  eat one candy from the box;  put five candies into the box; This way she will perform $$$9$$$ actions, the number of candies at the end will be $$$11$$$, while Alya will eat $$$4$$$ candies in total.You know the total number of actions $$$n$$$ and the number of candies at the end $$$k$$$. You need to find the total number of sweets Alya ate. That is the number of moves of the first option. It's guaranteed, that for the given $$$n$$$ and $$$k$$$ the answer always exists.Please note, that during an action of the first option, Alya takes out and eats exactly one candy.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^9$$$; $$$0 \le k \le 10^9$$$) — the total number of moves and the number of candies in the box at the end.  It's guaranteed, that for the given $$$n$$$ and $$$k$$$ the answer exists.

Print a single integer — the number of candies, which Alya ate. Please note, that in this problem there aren't multiple possible answers — the answer is unique for any input data.

NoteIn the first example, Alya has made one move only. According to the statement, the first move is always putting one candy in the box. Hence Alya ate $$$0$$$ candies.In the second example the possible sequence of Alya's actions looks as follows:   put $$$1$$$ candy,  put $$$2$$$ candies,  eat a candy,  eat a candy,  put $$$3$$$ candies,  eat a candy,  put $$$4$$$ candies,  eat a candy,  put $$$5$$$ candies.  This way, she will make exactly $$$n=9$$$ actions and in the end the box will contain $$$1+2-1-1+3-1+4-1+5=11$$$ candies. The answer is $$$4$$$, since she ate $$$4$$$ candies in total.


An n × n table a is defined as follows:  The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n.  Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table.You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above.

The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table.

Print a single line containing a positive integer m — the maximum value in the table.

NoteIn the second test the rows of the table look as follows: {1, 1, 1, 1, 1},  {1, 2, 3, 4, 5},  {1, 3, 6, 10, 15},  {1, 4, 10, 20, 35},  {1, 5, 15, 35, 70}.


Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the desks. The lanes are numbered from 1 to n from the left to the right, the desks in a lane are numbered from 1 to m starting from the blackboard. Note that the lanes go perpendicularly to the blackboard, not along it (see picture).The organizers numbered all the working places from 1 to 2nm. The places are numbered by lanes (i. e. all the places of the first lane go first, then all the places of the second lane, and so on), in a lane the places are numbered starting from the nearest to the blackboard (i. e. from the first desk in the lane), at each desk, the place on the left is numbered before the place on the right.    The picture illustrates the first and the second samples. Santa Clause knows that his place has number k. Help him to determine at which lane at which desk he should sit, and whether his place is on the left or on the right!

The only line contains three integers n, m and k (1 ≤ n, m ≤ 10 000, 1 ≤ k ≤ 2nm) — the number of lanes, the number of desks in each lane and the number of Santa Claus' place.

Print two integers: the number of lane r, the number of desk d, and a character s, which stands for the side of the desk Santa Claus. The character s should be "L", if Santa Clause should sit on the left, and "R" if his place is on the right.

NoteThe first and the second samples are shown on the picture. The green place corresponds to Santa Claus' place in the first example, the blue place corresponds to Santa Claus' place in the second example.In the third sample there are two lanes with four desks in each, and Santa Claus has the fourth place. Thus, his place is in the first lane at the second desk on the right.


John Doe decided that some mathematical object must be named after him. So he invented the Doe graphs. The Doe graphs are a family of undirected graphs, each of them is characterized by a single non-negative number — its order. We'll denote a graph of order k as D(k), and we'll denote the number of vertices in the graph D(k) as |D(k)|. Then let's define the Doe graphs as follows:  D(0) consists of a single vertex, that has number 1.  D(1) consists of two vertices with numbers 1 and 2, connected by an edge.  D(n) for n ≥ 2 is obtained from graphs D(n - 1) and D(n - 2). D(n - 1) and D(n - 2) are joined in one graph, at that numbers of all vertices of graph D(n - 2) increase by |D(n - 1)| (for example, vertex number 1 of graph D(n - 2) becomes vertex number 1 + |D(n - 1)|). After that two edges are added to the graph: the first one goes between vertices with numbers |D(n - 1)| and |D(n - 1)| + 1, the second one goes between vertices with numbers |D(n - 1)| + 1 and 1. Note that the definition of graph D(n) implies, that D(n) is a connected graph, its vertices are numbered from 1 to |D(n)|.   The picture shows the Doe graphs of order 1, 2, 3 and 4, from left to right. John thinks that Doe graphs are that great because for them exists a polynomial algorithm for the search of Hamiltonian path. However, your task is to answer queries of finding the shortest-length path between the vertices ai and bi in the graph D(n).A path between a pair of vertices u and v in the graph is a sequence of vertices x1, x2, ..., xk (k > 1) such, that x1 = u, xk = v, and for any i (i < k) vertices xi and xi + 1 are connected by a graph edge. The length of path x1, x2, ..., xk is number (k - 1).

The first line contains two integers t and n (1 ≤ t ≤ 105; 1 ≤ n ≤ 103) — the number of queries and the order of the given graph. The i-th of the next t lines contains two integers ai and bi (1 ≤ ai, bi ≤ 1016, ai ≠ bi) — numbers of two vertices in the i-th query. It is guaranteed that ai, bi ≤ |D(n)|. 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.

For each query print a single integer on a single line — the length of the shortest path between vertices ai and bi. Print the answers to the queries in the order, in which the queries are given in the input.


There are three doors in front of you, numbered from $$$1$$$ to $$$3$$$ from left to right. Each door has a lock on it, which can only be opened with a key with the same number on it as the number on the door.There are three keys — one for each door. Two of them are hidden behind the doors, so that there is no more than one key behind each door. So two doors have one key behind them, one door doesn't have a key behind it. To obtain a key hidden behind a door, you should first unlock that door. The remaining key is in your hands.Can you open all the doors?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 18$$$) — the number of testcases. The first line of each testcase contains a single integer $$$x$$$ ($$$1 \le x \le 3$$$) — the number on the key in your hands. The second line contains three integers $$$a, b$$$ and $$$c$$$ ($$$0 \le a, b, c \le 3$$$) — the number on the key behind each of the doors. If there is no key behind the door, the number is equal to $$$0$$$. Values $$$1, 2$$$ and $$$3$$$ appear exactly once among $$$x, a, b$$$ and $$$c$$$.

For each testcase, print "YES" if you can open all the doors. Otherwise, print "NO".


Mahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer n and then they take turns, starting from Mahmoud. In each player's turn, he has to choose an integer a and subtract it from n such that:  1 ≤ a ≤ n.  If it's Mahmoud's turn, a has to be even, but if it's Ehab's turn, a has to be odd. If the current player can't choose any number satisfying the conditions, he loses. Can you determine the winner if they both play optimally?

The only line contains an integer n (1 ≤ n ≤ 109), the number at the beginning of the game.

Output "Mahmoud" (without quotes) if Mahmoud wins and "Ehab" (without quotes) otherwise.

NoteIn the first sample, Mahmoud can't choose any integer a initially because there is no positive even integer less than or equal to 1 so Ehab wins.In the second sample, Mahmoud has to choose a = 2 and subtract it from n. It's Ehab's turn and n = 0. There is no positive odd integer less than or equal to 0 so Mahmoud wins.


Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into n consecutive segments, each segment needs to be painted in one of the colours.Arkady has already painted some (possibly none or all) segments and passes the paintbrush to you. You are to determine whether there are at least two ways of colouring all the unpainted segments so that no two adjacent segments are of the same colour. Two ways are considered different if and only if a segment is painted in different colours in them.

The first line contains a single positive integer n (1 ≤ n ≤ 100) — the length of the canvas. The second line contains a string s of n characters, the i-th of which is either 'C' (denoting a segment painted in cyan), 'M' (denoting one painted in magenta), 'Y' (one painted in yellow), or '?' (an unpainted one).

If there are at least two different ways of painting, output "Yes"; otherwise output "No" (both without quotes). You can print each character in any case (upper or lower).

NoteFor the first example, there are exactly two different ways of colouring: CYCMY and CYMCY.For the second example, there are also exactly two different ways of colouring: CMCMY and CYCMY.For the third example, there are four ways of colouring: MCYCM, MCYCY, YCYCM, and YCYCY.For the fourth example, no matter how the unpainted segments are coloured, the existing magenta segments will prevent the painting from satisfying the requirements. The similar is true for the fifth example.


There was once young lass called Mary,  Whose jokes were occasionally scary.  On this April's Fool  Fixed limerick rules  Allowed her to trip the unwary.Can she fill all the linesTo work at all times?On juggling the wordsRight around two-thirdsShe nearly ran out of rhymes.

The input contains a single integer $$$a$$$ ($$$4 \le a \le 998$$$). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer.


A stowaway and a controller play the following game. The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle. Every minute the players move.The controller's move is as follows. The controller has the movement direction — to the train's head or to its tail. During a move the controller moves to the neighbouring wagon correspondingly to its movement direction. If at the end of his move the controller enters the 1-st or the n-th wagon, that he changes the direction of his movement into the other one. In other words, the controller cyclically goes from the train's head to its tail and back again during all the time of a game, shifting during each move by one wagon. Note, that the controller always have exactly one possible move.The stowaway's move depends from the state of the train. If the train is moving, then the stowaway can shift to one of neighbouring wagons or he can stay where he is without moving. If the train is at a station and is idle, then the stowaway leaves the train (i.e. he is now not present in any train wagon) and then, if it is not the terminal train station, he enters the train again into any of n wagons (not necessarily into the one he's just left and not necessarily into the neighbouring one). If the train is idle for several minutes then each such minute the stowaway leaves the train and enters it back.Let's determine the order of the players' moves. If at the given minute the train is moving, then first the stowaway moves and then the controller does. If at this minute the train is idle, then first the stowaway leaves the train, then the controller moves and then the stowaway enters the train.If at some point in time the stowaway and the controller happen to be in one wagon, then the controller wins: he makes the stowaway pay fine. If after a while the stowaway reaches the terminal train station, then the stowaway wins: he simply leaves the station during his move and never returns there again.At any moment of time the players know each other's positions. The players play in the optimal way. Specifically, if the controller wins, then the stowaway plays so as to lose as late as possible. As all the possible moves for the controller are determined uniquely, then he is considered to play optimally always. Determine the winner.

The first line contains three integers n, m and k. They represent the number of wagons in the train, the stowaway's and the controller's initial positions correspondingly (2 ≤ n ≤ 50, 1 ≤ m, k ≤ n, m ≠ k). The second line contains the direction in which a controller moves. "to head" means that the controller moves to the train's head and "to tail" means that the controller moves to its tail. It is guaranteed that in the direction in which the controller is moving, there is at least one wagon. Wagon 1 is the head, and wagon n is the tail. The third line has the length from 1 to 200 and consists of symbols "0" and "1". The i-th symbol contains information about the train's state at the i-th minute of time. "0" means that in this very minute the train moves and "1" means that the train in this very minute stands idle. The last symbol of the third line is always "1" — that's the terminal train station.

If the stowaway wins, print "Stowaway" without quotes. Otherwise, print "Controller" again without quotes, then, separated by a space, print the number of a minute, at which the stowaway will be caught.


Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is concerned whether the table has enough space for plates for all those guests. Consider all plates to be round and have the same radii that equal r. Each plate must be completely inside the table and must touch the edge of the table. Of course, the plates must not intersect, but they can touch each other. Help Gerald determine whether the table is large enough for n plates.

The first line contains three integers n, R and r (1 ≤ n ≤ 100, 1 ≤ r, R ≤ 1000) — the number of plates, the radius of the table and the plates' radius.

Print "YES" (without the quotes) if it is possible to place n plates on the table by the rules given above. If it is impossible, print "NO". Remember, that each plate must touch the edge of the table.

NoteThe possible arrangement of the plates for the first sample is:


Natasha is planning an expedition to Mars for $$$n$$$ people. One of the important tasks is to provide food for each participant.The warehouse has $$$m$$$ daily food packages. Each package has some food type $$$a_i$$$.Each participant must eat exactly one food package each day. Due to extreme loads, each participant must eat the same food type throughout the expedition. Different participants may eat different (or the same) types of food.Formally, for each participant $$$j$$$ Natasha should select his food type $$$b_j$$$ and each day $$$j$$$-th participant will eat one food package of type $$$b_j$$$. The values $$$b_j$$$ for different participants may be different.What is the maximum possible number of days the expedition can last, following the requirements above?

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$1 \le m \le 100$$$) — the number of the expedition participants and the number of the daily food packages available. The second line contains sequence of integers $$$a_1, a_2, \dots, a_m$$$ ($$$1 \le a_i \le 100$$$), where $$$a_i$$$ is the type of $$$i$$$-th food package.

Print the single integer — the number of days the expedition can last. If it is not possible to plan the expedition for even one day, print 0.

NoteIn the first example, Natasha can assign type $$$1$$$ food to the first participant, the same type $$$1$$$ to the second, type $$$5$$$ to the third and type $$$2$$$ to the fourth. In this case, the expedition can last for $$$2$$$ days, since each participant can get two food packages of his food type (there will be used $$$4$$$ packages of type $$$1$$$, two packages of type $$$2$$$ and two packages of type $$$5$$$).In the second example, there are $$$100$$$ participants and only $$$1$$$ food package. In this case, the expedition can't last even $$$1$$$ day.


You are given a mysterious language (codenamed "Secret") available in "Custom Test" tab. Find out what this language is and write a program which outputs its name. Note that the program must be written in this language.

This program has only one test, and it's empty (it doesn't give your program anything to read).

Output the name of the mysterious language.


Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is "123456789101112131415...". Your task is to print the n-th digit of this string (digits are numbered starting with 1.

The only line of the input contains a single integer n (1 ≤ n ≤ 1000) — the position of the digit you need to print.

NoteIn the first sample the digit at position 3 is '3', as both integers 1 and 2 consist on one digit.In the second sample, the digit at position 11 is '0', it belongs to the integer 10.


Jeff loves regular bracket sequences.Today Jeff is going to take a piece of paper and write out the regular bracket sequence, consisting of nm brackets. Let's number all brackets of this sequence from 0 to nm - 1 from left to right. Jeff knows that he is going to spend ai mod n liters of ink on the i-th bracket of the sequence if he paints it opened and bi mod n liters if he paints it closed.You've got sequences a, b and numbers n, m. What minimum amount of ink will Jeff need to paint a regular bracket sequence of length nm?Operation x mod y means taking the remainder after dividing number x by number y.

The first line contains two integers n and m (1 ≤ n ≤ 20; 1 ≤ m ≤ 107; m is even). The next line contains n integers: a0, a1, ..., an - 1 (1 ≤ ai ≤ 10). The next line contains n integers: b0, b1, ..., bn - 1 (1 ≤ bi ≤ 10). The numbers are separated by spaces.

In a single line print the answer to the problem — the minimum required amount of ink in liters.

NoteIn the first test the optimal sequence is: ()()()()()(), the required number of ink liters is 12.


You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and exactly half of the players should play with their left hand. One player should use only on of his hands.Ambidexters play as well with their right hand as with their left hand. In the team, an ambidexter can play with their left hand, or with their right hand.Please find the maximum possible size of the team, where equal number of players use their left and right hands, respectively.

The only line contains three integers l, r and a (0 ≤ l, r, a ≤ 100) — the number of left-handers, the number of right-handers and the number of ambidexters at the training.

Print a single even integer — the maximum number of players in the team. It is possible that the team can only have zero number of players.

NoteIn the first example you can form a team of 6 players. You should take the only left-hander and two ambidexters to play with left hand, and three right-handers to play with right hand. The only person left can't be taken into the team.In the second example you can form a team of 14 people. You have to take all five left-handers, all five right-handers, two ambidexters to play with left hand and two ambidexters to play with right hand.


A frog is initially at position $$$0$$$ on the number line. The frog has two positive integers $$$a$$$ and $$$b$$$. From a position $$$k$$$, it can either jump to position $$$k+a$$$ or $$$k-b$$$.Let $$$f(x)$$$ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $$$[0, x]$$$. The frog doesn't need to visit all these integers in one trip, that is, an integer is counted if the frog can somehow reach it if it starts from $$$0$$$.Given an integer $$$m$$$, find $$$\sum_{i=0}^{m} f(i)$$$. That is, find the sum of all $$$f(i)$$$ for $$$i$$$ from $$$0$$$ to $$$m$$$.

The first line contains three integers $$$m, a, b$$$ ($$$1 \leq m \leq 10^9, 1 \leq a,b \leq 10^5$$$).

Print a single integer, the desired sum.

NoteIn the first example, we must find $$$f(0)+f(1)+\ldots+f(7)$$$. We have $$$f(0) = 1, f(1) = 1, f(2) = 1, f(3) = 1, f(4) = 1, f(5) = 3, f(6) = 3, f(7) = 8$$$. The sum of these values is $$$19$$$.In the second example, we have $$$f(i) = i+1$$$, so we want to find $$$\sum_{i=0}^{10^9} i+1$$$.In the third example, the frog can't make any jumps in any case.


Polycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm:   On the first step the string consists of a single character "a".  On the k-th step Polycarpus concatenates two copies of the string obtained on the (k - 1)-th step, while inserting the k-th character of the alphabet between them. Polycarpus uses the alphabet that consists of lowercase Latin letters and digits (a total of 36 characters). The alphabet characters are numbered like this: the 1-st character is "a", the 2-nd — "b", ..., the 26-th — "z", the 27-th — "0", the 28-th — "1", ..., the 36-th — "9". Let's have a closer look at the algorithm. On the second step Polycarpus will concatenate two strings "a" and insert the character "b" between them, resulting in "aba" string. The third step will transform it into "abacaba", and the fourth one - into "abacabadabacaba". Thus, the string constructed on the k-th step will consist of 2k - 1 characters. Polycarpus wrote down the string he got after 30 steps of the given algorithm and chose two non-empty substrings of it. Your task is to find the length of the longest common substring of the two substrings selected by Polycarpus.A substring s[i... j] (1 ≤ i ≤ j ≤ |s|) of string s = s1s2... s|s| is a string sisi + 1... sj. For example, substring s[2...4] of string s = "abacaba" equals "bac". The string is its own substring.The longest common substring of two strings s and t is the longest string that is a substring of both s and t. For example, the longest common substring of "contest" and "systemtesting" is string "test". There can be several common substrings of maximum length.

The input consists of a single line containing four integers l1, r1, l2, r2 (1 ≤ li ≤ ri ≤ 109, i = 1, 2). The numbers are separated by single spaces. li and ri give the indices of the first and the last characters of the i-th chosen substring, correspondingly (i = 1, 2). The characters of string abracadabra are numbered starting from 1.

Print a single number — the length of the longest common substring of the given strings. If there are no common substrings, print 0.

NoteIn the first sample the first substring is "acab", the second one is "abac". These two substrings have two longest common substrings "ac" and "ab", but we are only interested in their length — 2.In the second sample the first substring is "a", the second one is "c". These two substrings don't have any common characters, so the length of their longest common substring is 0.


One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbers from 1 to n to obtain total control over her energy.But his plan failed. The reason for this was very simple: Hexadecimal didn't perceive any information, apart from numbers written in binary format. This means that if a number in a decimal representation contained characters apart from 0 and 1, it was not stored in the memory. Now Megabyte wants to know, how many numbers were loaded successfully.

Input data contains the only number n (1 ≤ n ≤ 109).

Output the only number — answer to the problem.

NoteFor n = 10 the answer includes numbers 1 and 10.


InputThe input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive.OutputOutput "YES" or "NO".ExamplesInput
HELP
Output
YES
Input
AID
Output
NO
Input
MARY
Output
NO
Input
ANNA
Output
YES
Input
MUG
Output
YES
Input
CUP
Output
NO
Input
SUM
Output
YES
Input
PRODUCT
Output
NO


The citizens of BubbleLand are celebrating their 10th anniversary so they decided to organize a big music festival. Bob got a task to invite N famous singers who would sing on the fest. He was too busy placing stages for their performances that he totally forgot to write the invitation e-mails on time, and unfortunately he only found K available singers. Now there are more stages than singers, leaving some of the stages empty. Bob would not like if citizens of BubbleLand noticed empty stages and found out that he was irresponsible.Because of that he decided to choose exactly K stages that form a convex set, make large posters as edges of that convex set and hold festival inside. While those large posters will make it impossible for citizens to see empty stages outside Bob still needs to make sure they don't see any of the empty stages inside that area.Since lots of people are coming, he would like that the festival area is as large as possible. Help him calculate the maximum area that he could obtain respecting the conditions. If there is no such area, the festival cannot be organized and the answer is 0.00.

The first line of input contains two integers N (3 ≤ N ≤ 200) and K (3 ≤ K ≤ min(N, 50)), separated with one empty space, representing number of stages and number of singers, respectively. Each of the next N lines contains two integers Xi and Yi (0 ≤ Xi, Yi ≤ 106) representing the coordinates of the stages. There are no three or more collinear stages.

Output contains only one line with one number, rounded to exactly two decimal places: the maximal festival area. Rounding is performed so that 0.5 and more rounds up and everything else rounds down.

NoteExample explanation: From all possible convex polygon with 4 vertices and no other vertex inside, the largest is one with points (0, 0), (2, 1), (4, 4) and (1, 5).


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.


Once Vasya needed to transport m goats and m wolves from riverbank to the other as quickly as possible. The boat can hold n animals and Vasya, in addition, he is permitted to put less than n animals in the boat. If in one place (on one of the banks or in the boat) the wolves happen to strictly outnumber the goats, then the wolves eat the goats and Vasya gets upset. When Vasya swims on the boat from one shore to the other, he must take at least one animal to accompany him, otherwise he will get bored and he will, yet again, feel upset. When the boat reaches the bank, first all the animals get off simultaneously, and then the animals chosen by Vasya simultaneously get on the boat. That means that at the moment when the animals that have just arrived have already got off and the animals that are going to leave haven't yet got on, somebody might eat someone. Vasya needs to transport all the animals from one river bank to the other so that nobody eats anyone and Vasya doesn't get upset. What is the minimal number of times he will have to cross the river?

The first line contains two space-separated numbers m and n (1 ≤ m, n ≤ 105) — the number of animals and the boat's capacity.

If it is impossible to transport all the animals so that no one got upset, and all the goats survived, print -1. Otherwise print the single number — how many times Vasya will have to cross the river.

NoteThe first sample match to well-known problem for children.


You are given a regular polygon with $$$n$$$ vertices labeled from $$$1$$$ to $$$n$$$ in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the initial polygon, there is no pair of triangles such that their intersection has non-zero area, and the total area of all triangles is equal to the area of the given polygon. The weight of a triangulation is the sum of weigths of triangles it consists of, where the weight of a triagle is denoted as the product of labels of its vertices.Calculate the minimum weight among all triangulations of the polygon.

The first line contains single integer $$$n$$$ ($$$3 \le n \le 500$$$) — the number of vertices in the regular polygon.

Print one integer — the minimum weight among all triangulations of the given polygon.

NoteAccording to Wiki: polygon triangulation is the decomposition of a polygonal area (simple polygon) $$$P$$$ into a set of triangles, i. e., finding a set of triangles with pairwise non-intersecting interiors whose union is $$$P$$$.In the first example the polygon is a triangle, so we don't need to cut it further, so the answer is $$$1 \cdot 2 \cdot 3 = 6$$$.In the second example the polygon is a rectangle, so it should be divided into two triangles. It's optimal to cut it using diagonal $$$1-3$$$ so answer is $$$1 \cdot 2 \cdot 3 + 1 \cdot 3 \cdot 4 = 6 + 12 = 18$$$.


Alice and Bob are playing a game with $$$n$$$ piles of stones. It is guaranteed that $$$n$$$ is an even number. The $$$i$$$-th pile has $$$a_i$$$ stones.Alice and Bob will play a game alternating turns with Alice going first.On a player's turn, they must choose exactly $$$\frac{n}{2}$$$ nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than $$$\frac{n}{2}$$$ nonempty piles).Given the starting configuration, determine who will win the game.

The first line contains one integer $$$n$$$ ($$$2 \leq n \leq 50$$$) — the number of piles. It is guaranteed that $$$n$$$ is an even number. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 50$$$) — the number of stones in the piles.

Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes).

NoteIn the first example, each player can only remove stones from one pile ($$$\frac{2}{2}=1$$$). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first.In the second example, Alice can remove $$$2$$$ stones from the first pile and $$$3$$$ stones from the third pile on her first move to guarantee a win.


Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.

The first line contains integers n, a, b (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly. The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes. Assume that the apples are numbered from 1 to n. The input is such that the answer exists.

Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.


ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once. In particular, if the string has length strictly less than 26, no such substring exists and thus it is not nice.Now, ZS the Coder tells you a word, where some of its letters are missing as he forgot them. He wants to determine if it is possible to fill in the missing letters so that the resulting word is nice. If it is possible, he needs you to find an example of such a word as well. Can you help him?

The first and only line of the input contains a single string s (1 ≤ |s| ≤ 50 000), the word that ZS the Coder remembers. Each character of the string is the uppercase letter of English alphabet ('A'-'Z') or is a question mark ('?'), where the question marks denotes the letters that ZS the Coder can't remember.

If there is no way to replace all the question marks with uppercase letters such that the resulting word is nice, then print  - 1 in the only line. Otherwise, print a string which denotes a possible nice word that ZS the Coder learned. This string should match the string from the input, except for the question marks replaced with uppercase English letters. If there are multiple solutions, you may print any of them.

NoteIn the first sample case, ABCDEFGHIJKLMNOPQRZTUVWXYS is a valid answer beacuse it contains a substring of length 26 (the whole string in this case) which contains all the letters of the English alphabet exactly once. Note that there are many possible solutions, such as ABCDEFGHIJKLMNOPQRSTUVWXYZ or ABCEDFGHIJKLMNOPQRZTUVWXYS.In the second sample case, there are no missing letters. In addition, the given string does not have a substring of length 26 that contains all the letters of the alphabet, so the answer is  - 1.In the third sample case, any string of length 26 that contains all letters of the English alphabet fits as an answer.


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.


Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number the floors from bottom to top with integers from 1 to n. Now you're on the floor number a. You are very bored, so you want to take the lift. Floor number b has a secret lab, the entry is forbidden. However, you already are in the mood and decide to make k consecutive trips in the lift.Let us suppose that at the moment you are on the floor number x (initially, you were on floor a). For another trip between floors you choose some floor with number y (y ≠ x) and the lift travels to this floor. As you cannot visit floor b with the secret lab, you decided that the distance from the current floor x to the chosen y must be strictly less than the distance from the current floor x to floor b with the secret lab. Formally, it means that the following inequation must fulfill: |x - y| < |x - b|. After the lift successfully transports you to floor y, you write down number y in your notepad.Your task is to find the number of distinct number sequences that you could have written in the notebook as the result of k trips in the lift. As the sought number of trips can be rather large, find the remainder after dividing the number by 1000000007 (109 + 7).

The first line of the input contains four space-separated integers n, a, b, k (2 ≤ n ≤ 5000, 1 ≤ k ≤ 5000, 1 ≤ a, b ≤ n, a ≠ b).

Print a single integer — the remainder after dividing the sought number of sequences by 1000000007 (109 + 7).

NoteTwo sequences p1, p2, ..., pk and q1, q2, ..., qk are distinct, if there is such integer j (1 ≤ j ≤ k), that pj ≠ qj.Notes to the samples:  In the first sample after the first trip you are either on floor 1, or on floor 3, because |1 - 2| < |2 - 4| and |3 - 2| < |2 - 4|.  In the second sample there are two possible sequences: (1, 2); (1, 3). You cannot choose floor 3 for the first trip because in this case no floor can be the floor for the second trip.  In the third sample there are no sought sequences, because you cannot choose the floor for the first trip.


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.


A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels. Your task is to determine the size of the rectangular display — the number of lines (rows) of pixels a and the number of columns of pixels b, so that:  there are exactly n pixels on the display;  the number of rows does not exceed the number of columns, it means a ≤ b;  the difference b - a is as small as possible.

The first line contains the positive integer n (1 ≤ n ≤ 106) — the number of pixels display should have.

Print two integers — the number of rows and columns on the display.

NoteIn the first example the minimum possible difference equals 2, so on the display should be 2 rows of 4 pixels.In the second example the minimum possible difference equals 0, so on the display should be 8 rows of 8 pixels.In the third example the minimum possible difference equals 4, so on the display should be 1 row of 5 pixels.


A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).Consider a permutation $$$p$$$ of length $$$n$$$, we build a graph of size $$$n$$$ using it as follows:   For every $$$1 \leq i \leq n$$$, find the largest $$$j$$$ such that $$$1 \leq j < i$$$ and $$$p_j > p_i$$$, and add an undirected edge between node $$$i$$$ and node $$$j$$$  For every $$$1 \leq i \leq n$$$, find the smallest $$$j$$$ such that $$$i < j \leq n$$$ and $$$p_j > p_i$$$, and add an undirected edge between node $$$i$$$ and node $$$j$$$ In cases where no such $$$j$$$ exists, we make no edges. Also, note that we make edges between the corresponding indices, not the values at those indices.For clarity, consider as an example $$$n = 4$$$, and $$$p = [3,1,4,2]$$$; here, the edges of the graph are $$$(1,3),(2,1),(2,3),(4,3)$$$.A permutation $$$p$$$ is cyclic if the graph built using $$$p$$$ has at least one simple cycle. Given $$$n$$$, find the number of cyclic permutations of length $$$n$$$. Since the number may be very large, output it modulo $$$10^9+7$$$.Please refer to the Notes section for the formal definition of a simple cycle

The first and only line contains a single integer $$$n$$$ ($$$3 \le n \le 10^6$$$).

Output a single integer $$$0 \leq x < 10^9+7$$$, the number of cyclic permutations of length $$$n$$$ modulo $$$10^9+7$$$.

NoteThere are $$$16$$$ cyclic permutations for $$$n = 4$$$. $$$[4,2,1,3]$$$ is one such permutation, having a cycle of length four: $$$4 \rightarrow 3 \rightarrow 2 \rightarrow 1 \rightarrow 4$$$.Nodes $$$v_1$$$, $$$v_2$$$, $$$\ldots$$$, $$$v_k$$$ form a simple cycle if the following conditions hold:   $$$k \geq 3$$$.  $$$v_i \neq v_j$$$ for any pair of indices $$$i$$$ and $$$j$$$. ($$$1 \leq i < j \leq k$$$)  $$$v_i$$$ and $$$v_{i+1}$$$ share an edge for all $$$i$$$ ($$$1 \leq i < k$$$), and $$$v_1$$$ and $$$v_k$$$ share an edge.


Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!Since you are so curious about Bitland, I'll give you the chance of peeking at one of these games.BitLGM and BitAryo are playing yet another of their crazy-looking genius-needed Bitlandish games. They've got a sequence of n non-negative integers a1, a2, ..., an. The players make moves in turns. BitLGM moves first. Each player can and must do one of the two following actions in his turn:  Take one of the integers (we'll denote it as ai). Choose integer x (1 ≤ x ≤ ai). And then decrease ai by x, that is, apply assignment: ai = ai - x.  Choose integer x . And then decrease all ai by x, that is, apply assignment: ai = ai - x, for all i. The player who cannot make a move loses.You're given the initial sequence a1, a2, ..., an. Determine who wins, if both players plays optimally well and if BitLGM and BitAryo start playing the described game in this sequence.

The first line contains an integer n (1 ≤ n ≤ 3). The next line contains n integers a1, a2, ..., an (0 ≤ ai < 300).

Write the name of the winner (provided that both players play optimally well). Either "BitLGM" or "BitAryo" (without the quotes).


You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...You are given an array of integers. Sort it in non-descending order.

The input consists of a single line of space-separated integers. The first number is n (1 ≤ n ≤ 10) — the size of the array. The following n numbers are the elements of the array (1 ≤ ai ≤ 100).

Output space-separated elements of the sorted array.

NoteRemember, this is a very important feature, and you have to make sure the customers appreciate it!


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


zscoder has a deck of $$$n+m$$$ custom-made cards, which consists of $$$n$$$ cards labelled from $$$1$$$ to $$$n$$$ and $$$m$$$ jokers. Since zscoder is lonely, he wants to play a game with himself using those cards. Initially, the deck is shuffled uniformly randomly and placed on the table. zscoder has a set $$$S$$$ which is initially empty. Every second, zscoder draws the top card from the deck.   If the card has a number $$$x$$$ written on it, zscoder removes the card and adds $$$x$$$ to the set $$$S$$$.  If the card drawn is a joker, zscoder places all the cards back into the deck and reshuffles (uniformly randomly) the $$$n+m$$$ cards to form a new deck (hence the new deck now contains all cards from $$$1$$$ to $$$n$$$ and the $$$m$$$ jokers). Then, if $$$S$$$ currently contains all the elements from $$$1$$$ to $$$n$$$, the game ends. Shuffling the deck doesn't take time at all. What is the expected number of seconds before the game ends? We can show that the answer can be written in the form $$$\frac{P}{Q}$$$ where $$$P, Q$$$ are relatively prime integers and $$$Q \neq 0 \bmod 998244353$$$. Output the value of $$$(P \cdot Q^{-1})$$$ modulo $$$998244353$$$.

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

Output a single integer, the value of $$$(P \cdot Q^{-1})$$$ modulo $$$998244353$$$.

NoteFor the first sample, it can be proven that the expected time before the game ends is $$$5$$$ seconds.For the second sample, it can be proven that the expected time before the game ends is $$$\frac{28}{3}$$$ seconds.


Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately.Organizers are still arranging tournament grid (i.e. the order games will happen and who is going to play with whom) but they have already fixed one rule: two players can play against each other only if the number of games one of them has already played differs by no more than one from the number of games the other one has already played. Of course, both players had to win all their games in order to continue participating in the tournament.Tournament hasn't started yet so the audience is a bit bored. Ostap decided to find out what is the maximum number of games the winner of the tournament can take part in (assuming the rule above is used). However, it is unlikely he can deal with this problem without your help.

The only line of the input contains a single integer n (2 ≤ n ≤ 1018) — the number of players to participate in the tournament.

Print the maximum number of games in which the winner of the tournament can take part.

NoteIn all samples we consider that player number 1 is the winner.In the first sample, there would be only one game so the answer is 1.In the second sample, player 1 can consequently beat players 2 and 3. In the third sample, player 1 can't play with each other player as after he plays with players 2 and 3 he can't play against player 4, as he has 0 games played, while player 1 already played 2. Thus, the answer is 2 and to achieve we make pairs (1, 2) and (3, 4) and then clash the winners.


In Omkar's last class of math, he learned about the least common multiple, or $$$LCM$$$. $$$LCM(a, b)$$$ is the smallest positive integer $$$x$$$ which is divisible by both $$$a$$$ and $$$b$$$.Omkar, having a laudably curious mind, immediately thought of a problem involving the $$$LCM$$$ operation: given an integer $$$n$$$, find positive integers $$$a$$$ and $$$b$$$ such that $$$a + b = n$$$ and $$$LCM(a, b)$$$ is the minimum value possible.Can you help Omkar solve his ludicrously challenging math problem?

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10$$$). Description of the test cases follows. Each test case consists of a single integer $$$n$$$ ($$$2 \leq n \leq 10^{9}$$$).

For each test case, output two positive integers $$$a$$$ and $$$b$$$, such that $$$a + b = n$$$ and $$$LCM(a, b)$$$ is the minimum possible.

NoteFor the first test case, the numbers we can choose are $$$1, 3$$$ or $$$2, 2$$$. $$$LCM(1, 3) = 3$$$ and $$$LCM(2, 2) = 2$$$, so we output $$$2 \ 2$$$.For the second test case, the numbers we can choose are $$$1, 5$$$, $$$2, 4$$$, or $$$3, 3$$$. $$$LCM(1, 5) = 5$$$, $$$LCM(2, 4) = 4$$$, and $$$LCM(3, 3) = 3$$$, so we output $$$3 \ 3$$$.For the third test case, $$$LCM(3, 6) = 6$$$. It can be shown that there are no other pairs of numbers which sum to $$$9$$$ that have a lower $$$LCM$$$.


Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consecutive vowels in the word, it deletes the first vowel in a word such that there is another vowel right before it. If there are no two consecutive vowels in the word, it is considered to be correct.You are given a word s. Can you predict what will it become after correction?In this problem letters a, e, i, o, u and y are considered to be vowels.

The first line contains one integer n (1 ≤ n ≤ 100) — the number of letters in word s before the correction. The second line contains a string s consisting of exactly n lowercase Latin letters — the word before the correction.

NoteExplanations of the examples:  There is only one replace: weird  werd; No replace needed since there are no two consecutive vowels; aaeaa  aeaa  aaa  aa  a.


You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.

The single line contains 4 integers a, b, c, l (1 ≤ a, b, c ≤ 3·105, 0 ≤ l ≤ 3·105).

Print a single integer — the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.

NoteIn the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.


This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.You are given string s consisting of lowercase English letters only. Find its lexicographically largest palindromic subsequence.We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk (1  ≤  p1 < p2 < ... < pk  ≤  |s|) a subsequence of string s = s1s2... s|s|, where |s| is the length of string s. For example, strings "abcb", "b" and "abacaba" are subsequences of string "abacaba".String x = x1x2... x|x| is lexicographically larger than string y = y1y2... y|y| if either |x| > |y| and x1 = y1, x2 = y2, ..., x|y| = y|y|, or there exists such number r (r < |x|, r < |y|) that x1 = y1, x2 = y2, ..., xr = yr and xr  +  1 > yr  +  1. Characters in the strings are compared according to their ASCII codes. For example, string "ranger" is lexicographically larger than string "racecar" and string "poster" is lexicographically larger than string "post".String s = s1s2... s|s| is a palindrome if it matches string rev(s) = s|s|s|s| - 1... s1. In other words, a string is a palindrome if it reads the same way from left to right and from right to left. For example, palindromic strings are "racecar", "refer" and "z".

The only input line contains a non-empty string s consisting of lowercase English letters only. Its length does not exceed 10.

Print the lexicographically largest palindromic subsequence of string s.

NoteAmong all distinct subsequences of string "radar" the following ones are palindromes: "a", "d", "r", "aa", "rr", "ada", "rar", "rdr", "raar" and "radar". The lexicographically largest of them is "rr".


By the year 3018, Summer Informatics School has greatly grown. Hotel «Berendeetronik» has been chosen as a location of the school. The camp consists of $$$n$$$ houses with $$$n-1$$$ pathways between them. It is possible to reach every house from each other using the pathways.Everything had been perfect until the rains started. The weather forecast promises that rains will continue for $$$m$$$ days. A special squad of teachers was able to measure that the $$$i$$$-th pathway, connecting houses $$$u_i$$$ and $$$v_i$$$, before the rain could be passed in $$$b_i$$$ seconds. Unfortunately, the rain erodes the roads, so with every day the time to pass the road will increase by $$$a_i$$$ seconds. In other words, on the $$$t$$$-th (from zero) day after the start of the rain, it will take $$$a_i \cdot t + b_i$$$ seconds to pass through this road.Unfortunately, despite all the efforts of teachers, even in the year 3018 not all the students are in their houses by midnight. As by midnight all students have to go to bed, it is important to find the maximal time between all the pairs of houses for each day, so every student would know the time when he has to run to his house.Find all the maximal times of paths between every pairs of houses after $$$t=0$$$, $$$t=1$$$, ..., $$$t=m-1$$$ days.

In the first line you are given two integers $$$n$$$ and $$$m$$$ — the number of houses in the camp and the number of raining days ($$$1 \le n \le 100\,000$$$; $$$1 \le m \le 1\,000\,000$$$). In the next $$$n-1$$$ lines you are given the integers $$$u_i$$$, $$$v_i$$$, $$$a_i$$$, $$$b_i$$$ — description of pathways ($$$1 \le u_i, v_i \le n$$$; $$$0 \le a_i \le 10^5$$$; $$$0 \le b_i \le 10^9$$$). $$$i$$$-th pathway connects houses $$$u_i$$$ and $$$v_i$$$, and in day $$$t$$$ requires $$$a_i \cdot t + b_i$$$ seconds to pass through. It is guaranteed that every two houses are connected by a sequence of pathways.

Print $$$m$$$ integers — the lengths of the longest path in the camp after a $$$t=0, t=1, \ldots, t=m-1$$$ days after the start of the rain.

NoteLet's consider the first example.In the first three days ($$$0 \le t \le 2$$$) the longest path is between 2nd and 3rd houses, and its length is equal to $$$100+100=200$$$ seconds.In the third day ($$$t=2$$$) the road between houses 1 and 4 has length $$$100$$$ and keeps increasing. So, in days $$$t=2, 3, 4, 5$$$ the longest path is between vertices 4 and (1 or 2), and has length $$$180+10t$$$. Notice, that in the day $$$t=2$$$ there are three pathways with length 100, so there are three maximal paths of equal length.In the sixth day ($$$t=5$$$) pathway between first and fifth houses get length 100. So in every day with $$$t=5$$$ and further the longest path is between houses 4 and 5 and has length $$$80+30t$$$.


Madoka decided to entrust the organization of a major computer game tournament "OSU"!In this tournament, matches are held according to the "Olympic system". In other words, there are $$$2^n$$$ participants in the tournament, numbered with integers from $$$1$$$ to $$$2^n$$$. There are $$$n$$$ rounds in total in the tournament. In the $$$i$$$-th round there are $$$2^{n - i}$$$ matches between two players (one of whom is right, the other is left), after which the winners go further along the tournament grid, and the losing participants are eliminated from the tournament. Herewith, the relative order in the next round does not change. And the winner of the tournament — is the last remaining participant.But the smaller the participant's number, the more he will pay Madoka if he wins, so Madoka wants the participant with the lowest number to win. To do this, she can arrange the participants in the first round as she likes, and also determine for each match who will win — the participant on the left or right.But Madoka knows that tournament sponsors can change the winner in matches no more than $$$k$$$ times. (That is, if the participant on the left won before the change, then the participant on the right will win after the change, and if the participant on the right won, then the participant on the left will win after the change).  So, the first image shows the tournament grid that Madoka made, where the red lines denote who should win the match. And the second one shows the tournament grid, after one change in the outcome of the match by sponsors (a match between $$$1$$$ and $$$3$$$ players). Print the minimum possible number of the winner in the tournament, which Madoka can get regardless of changes in sponsors. But since the answer can be very large, output it modulo $$$10^9 + 7$$$. Note that we need to minimize the answer, and only then take it modulo.

The first and the only line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^5, 1 \le k \le \min(2^n - 1, 10^9)$$$) — the number of rounds in the tournament and the number of outcomes that sponsors can change.

Print exactly one integer — the minimum number of the winner modulo $$$10^9 + 7$$$

NoteIn the first example, there is only one match between players $$$1$$$ and $$$2$$$, so the sponsors can always make player $$$2$$$ wins.The tournament grid from the second example is shown in the picture in the statement.


Dreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them.Each command is one of the following two types:   Go 1 unit towards the positive direction, denoted as '+'  Go 1 unit towards the negative direction, denoted as '-' But the Wi-Fi condition is so poor that Dreamoon's smartphone reports some of the commands can't be recognized and Dreamoon knows that some of them might even be wrong though successfully recognized. Dreamoon decides to follow every recognized command and toss a fair coin to decide those unrecognized ones (that means, he moves to the 1 unit to the negative or positive direction with the same probability 0.5). You are given an original list of commands sent by Drazil and list received by Dreamoon. What is the probability that Dreamoon ends in the position originally supposed to be final by Drazil's commands?

The first line contains a string s1 — the commands Drazil sends to Dreamoon, this string consists of only the characters in the set {'+', '-'}.  The second line contains a string s2 — the commands Dreamoon's smartphone recognizes, this string consists of only the characters in the set {'+', '-', '?'}. '?' denotes an unrecognized command. Lengths of two strings are equal and do not exceed 10.

Output a single real number corresponding to the probability. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 9.

NoteFor the first sample, both s1 and s2 will lead Dreamoon to finish at the same position  + 1. For the second sample, s1 will lead Dreamoon to finish at position 0, while there are four possibilites for s2: {"+-++", "+-+-", "+--+", "+---"} with ending position {+2, 0, 0, -2} respectively. So there are 2 correct cases out of 4, so the probability of finishing at the correct position is 0.5. For the third sample, s2 could only lead us to finish at positions {+1, -1, -3}, so the probability to finish at the correct position  + 3 is 0.


Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every  the condition ai ≥ ai - 1 is met, so the sequence is sorted.Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai ().Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously.

The first line contains three integers n, k, x (1 ≤ k ≤ n ≤ 100, 1 ≤ x ≤ 99) — the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≤ ai ≤ 100) — the time Luba has to spend to do i-th chore. It is guaranteed that , and for each  ai ≥ ai - 1.

Print one number — minimum time Luba needs to do all n chores.

NoteIn the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13.In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100·3 + 2·1 = 302.


At a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform the following operations with vector А: Turn the vector by 90 degrees clockwise. Add to the vector a certain vector C.Operations could be performed in any order any number of times.Can Gerald cope with the task?

The first line contains integers x1 и y1 — the coordinates of the vector A ( - 108 ≤ x1, y1 ≤ 108). The second and the third line contain in the similar manner vectors B and C (their coordinates are integers; their absolute value does not exceed 108).

Print "YES" (without the quotes) if it is possible to get vector B using the given operations. Otherwise print "NO" (without the quotes).


Today, Mezo is playing a game. Zoma, a character in that game, is initially at position $$$x = 0$$$. Mezo starts sending $$$n$$$ commands to Zoma. There are two possible commands:  'L' (Left) sets the position $$$x: =x - 1$$$;  'R' (Right) sets the position $$$x: =x + 1$$$. Unfortunately, Mezo's controller malfunctions sometimes. Some commands are sent successfully and some are ignored. If the command is ignored then the position $$$x$$$ doesn't change and Mezo simply proceeds to the next command.For example, if Mezo sends commands "LRLR", then here are some possible outcomes (underlined commands are sent successfully):   "LRLR" — Zoma moves to the left, to the right, to the left again and to the right for the final time, ending up at position $$$0$$$;  "LRLR" — Zoma recieves no commands, doesn't move at all and ends up at position $$$0$$$ as well;  "LRLR" — Zoma moves to the left, then to the left again and ends up in position $$$-2$$$. Mezo doesn't know which commands will be sent successfully beforehand. Thus, he wants to know how many different positions may Zoma end up at.

The first line contains $$$n$$$ $$$(1 \le n \le 10^5)$$$ — the number of commands Mezo sends. The second line contains a string $$$s$$$ of $$$n$$$ commands, each either 'L' (Left) or 'R' (Right).

Print one integer — the number of different positions Zoma may end up at.

NoteIn the example, Zoma may end up anywhere between $$$-2$$$ and $$$2$$$.