— Thanks a lot for today.— I experienced so many great things.— You gave me memories like dreams... But I have to leave now...— One last request, can you...— Help me solve a Codeforces problem?— ......— What?Chtholly has been thinking about a problem for days:If a number is palindrome and length of its decimal representation without leading zeros is even, we call it a zcy number. A number is palindrome means when written in decimal representation, it contains no leading zeros and reads the same forwards and backwards. For example 12321 and 1221 are palindromes and 123 and 12451 are not. Moreover, 1221 is zcy number and 12321 is not.Given integers k and p, calculate the sum of the k smallest zcy numbers and output this sum modulo p.Unfortunately, Willem isn't good at solving this kind of problems, so he asks you for help!

The first line contains two integers k and p (1 ≤ k ≤ 105, 1 ≤ p ≤ 109).

Output single integer — answer to the problem.

NoteIn the first example, the smallest zcy number is 11, and the second smallest zcy number is 22.In the second example, .


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

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

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


InputThe input contains two integers $$$N$$$, $$$M$$$ ($$$1 \le N \le 1024, 2 \le M \le 16$$$), separated by a single space.OutputOutput "YES" or "NO".ExamplesInput
2 3
Output
YES
Input
3 2
Output
NO
Input
33 16
Output
YES
Input
26 5
Output
NO


A little girl loves problems on bitwise operations very much. Here's one of them.You are given two integers l and r. Let's consider the values of  for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones.Expression  means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as "xor".

The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

In a single line print a single integer — the maximum value of  for all pairs of integers a, b (l ≤ a ≤ b ≤ r).


Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant "n"; after this letter, there can be any letter (not only a vowel) or there can be no letter at all. For example, the words "harakiri", "yupie", "man", and "nbo" are Berlanese while the words "horse", "king", "my", and "nz" are not.Help Vitya find out if a word $$$s$$$ is Berlanese.

The first line of the input contains the string $$$s$$$ consisting of $$$|s|$$$ ($$$1\leq |s|\leq 100$$$) lowercase Latin letters.

Print "YES" (without quotes) if there is a vowel after every consonant except "n", otherwise print "NO". You can print each letter in any case (upper or lower).

NoteIn the first and second samples, a vowel goes after each consonant except "n", so the word is Berlanese.In the third sample, the consonant "c" goes after the consonant "r", and the consonant "s" stands on the end, so the word is not Berlanese.


Like any unknown mathematician, Yuri has favourite numbers: $$$A$$$, $$$B$$$, $$$C$$$, and $$$D$$$, where $$$A \leq B \leq C \leq D$$$. Yuri also likes triangles and once he thought: how many non-degenerate triangles with integer sides $$$x$$$, $$$y$$$, and $$$z$$$ exist, such that $$$A \leq x \leq B \leq y \leq C \leq z \leq D$$$ holds?Yuri is preparing problems for a new contest now, so he is very busy. That's why he asked you to calculate the number of triangles with described property.The triangle is called non-degenerate if and only if its vertices are not collinear.

The first line contains four integers: $$$A$$$, $$$B$$$, $$$C$$$ and $$$D$$$ ($$$1 \leq A \leq B \leq C \leq D \leq 5 \cdot 10^5$$$) — Yuri's favourite numbers.

Print the number of non-degenerate triangles with integer sides $$$x$$$, $$$y$$$, and $$$z$$$ such that the inequality $$$A \leq x \leq B \leq y \leq C \leq z \leq D$$$ holds.

NoteIn the first example Yuri can make up triangles with sides $$$(1, 3, 3)$$$, $$$(2, 2, 3)$$$, $$$(2, 3, 3)$$$ and $$$(2, 3, 4)$$$.In the second example Yuri can make up triangles with sides $$$(1, 2, 2)$$$, $$$(2, 2, 2)$$$ and $$$(2, 2, 3)$$$.In the third example Yuri can make up only one equilateral triangle with sides equal to $$$5 \cdot 10^5$$$.


You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Sylveon.You know the length of the word in the crossword, and you already know some letters. Designers of the crossword made sure that the answer is unambiguous, so you can assume that exactly one pokemon out of the 8 that Eevee evolves into fits the length and the letters given. Your task is to find it.

First line contains an integer n (6 ≤ n ≤ 8) – the length of the string. Next line contains a string consisting of n characters, each of which is either a lower case english letter (indicating a known letter) or a dot character (indicating an empty cell in the crossword).

Print a name of the pokemon that Eevee can evolve into that matches the pattern in the input. Use lower case letters only to print the name (in particular, do not capitalize the first letter).

NoteHere's a set of names in a form you can paste into your solution:["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]{"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"}


Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three.So they play with each other according to following rules:  Alex and Bob play the first game, and Carl is spectating;  When the game ends, the one who lost the game becomes the spectator in the next game, and the one who was spectating plays against the winner. Alex, Bob and Carl play in such a way that there are no draws.Today they have played n games, and for each of these games they remember who was the winner. They decided to make up a log of games describing who won each game. But now they doubt if the information in the log is correct, and they want to know if the situation described in the log they made up was possible (that is, no game is won by someone who is spectating if Alex, Bob and Carl play according to the rules). Help them to check it!

The first line contains one integer n (1 ≤ n ≤ 100) — the number of games Alex, Bob and Carl played. Then n lines follow, describing the game log. i-th line contains one integer ai (1 ≤ ai ≤ 3) which is equal to 1 if Alex won i-th game, to 2 if Bob won i-th game and 3 if Carl won i-th game.

Print YES if the situation described in the log was possible. Otherwise print NO.

NoteIn the first example the possible situation is:  Alex wins, Carl starts playing instead of Bob;  Alex wins, Bob replaces Carl;  Bob wins. The situation in the second example is impossible because Bob loses the first game, so he cannot win the second one.


Two-gram is an ordered pair (i.e. string of length two) of capital Latin letters. For example, "AZ", "AA", "ZA" — three distinct two-grams.You are given a string $$$s$$$ consisting of $$$n$$$ capital Latin letters. Your task is to find any two-gram contained in the given string as a substring (i.e. two consecutive characters of the string) maximal number of times. For example, for string $$$s$$$ = "BBAABBBA" the answer is two-gram "BB", which contained in $$$s$$$ three times. In other words, find any most frequent two-gram.Note that occurrences of the two-gram can overlap with each other.

The first line of the input contains integer number $$$n$$$ ($$$2 \le n \le 100$$$) — the length of string $$$s$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ capital Latin letters.

Print the only line containing exactly two capital Latin letters — any two-gram contained in the given string $$$s$$$ as a substring (i.e. two consecutive characters of the string) maximal number of times.

NoteIn the first example "BA" is also valid answer.In the second example the only two-gram "ZZ" can be printed because it contained in the string "ZZZAA" two times.


Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.Kolya is hungry, so he went to the nearest milk shop. In 2084 you may buy kefir in a plastic liter bottle, that costs a rubles, or in glass liter bottle, that costs b rubles. Also, you may return empty glass bottle and get c (c < b) rubles back, but you cannot return plastic bottles.Kolya has n rubles and he is really hungry, so he wants to drink as much kefir as possible. There were no plastic bottles in his 1984, so Kolya doesn't know how to act optimally and asks for your help.

First line of the input contains a single integer n (1 ≤ n ≤ 1018) — the number of rubles Kolya has at the beginning. Then follow three lines containing integers a, b and c (1 ≤ a ≤ 1018, 1 ≤ c < b ≤ 1018) — the cost of one plastic liter bottle, the cost of one glass liter bottle and the money one can get back by returning an empty glass bottle, respectively.

Print the only integer — maximum number of liters of kefir, that Kolya can drink.

NoteIn the first sample, Kolya can buy one glass bottle, then return it and buy one more glass bottle. Thus he will drink 2 liters of kefir.In the second sample, Kolya can buy two plastic bottle and get two liters of kefir, or he can buy one liter glass bottle, then return it and buy one plastic bottle. In both cases he will drink two liters of kefir.


The king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and competing. Recently Copa understood that to conquer the world he needs to organize the world Codeforces tournament. He hopes that after it the brightest minds will become his subordinates, and the toughest part of conquering the world will be completed.The final round of the Codeforces World Finals 20YY is scheduled for DD.MM.YY, where DD is the day of the round, MM is the month and YY are the last two digits of the year. Bob is lucky to be the first finalist form Berland. But there is one problem: according to the rules of the competition, all participants must be at least 18 years old at the moment of the finals. Bob was born on BD.BM.BY. This date is recorded in his passport, the copy of which he has already mailed to the organizers. But Bob learned that in different countries the way, in which the dates are written, differs. For example, in the US the month is written first, then the day and finally the year. Bob wonders if it is possible to rearrange the numbers in his date of birth so that he will be at least 18 years old on the day DD.MM.YY. He can always tell that in his motherland dates are written differently. Help him.According to another strange rule, eligible participant must be born in the same century as the date of the finals. If the day of the finals is participant's 18-th birthday, he is allowed to participate. As we are considering only the years from 2001 to 2099 for the year of the finals, use the following rule: the year is leap if it's number is divisible by four.

The first line contains the date DD.MM.YY, the second line contains the date BD.BM.BY. It is guaranteed that both dates are correct, and YY and BY are always in [01;99]. It could be that by passport Bob was born after the finals. In this case, he can still change the order of numbers in date.

If it is possible to rearrange the numbers in the date of birth so that Bob will be at least 18 years old on the DD.MM.YY, output YES. In the other case, output NO.  Each number contains exactly two digits and stands for day, month or year in a date. Note that it is permitted to rearrange only numbers, not digits.


Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.Embosser is a special devise that allows to "print" the text of a plastic tape. Text is printed sequentially, character by character. The device consists of a wheel with a lowercase English letters written in a circle, static pointer to the current letter and a button that print the chosen letter. At one move it's allowed to rotate the alphabetic wheel one step clockwise or counterclockwise. Initially, static pointer points to letter 'a'. Other letters are located as shown on the picture:  After Grigoriy add new item to the base he has to print its name on the plastic tape and attach it to the corresponding exhibit. It's not required to return the wheel to its initial position with pointer on the letter 'a'.Our hero is afraid that some exhibits may become alive and start to attack him, so he wants to print the names as fast as possible. Help him, for the given string find the minimum number of rotations of the wheel required to print it.

The only line of input contains the name of some exhibit — the non-empty string consisting of no more than 100 characters. It's guaranteed that the string consists of only lowercase English letters.

Print one integer — the minimum number of rotations of the wheel, required to print the name given in the input.

Note   To print the string from the first sample it would be optimal to perform the following sequence of rotations:   from 'a' to 'z' (1 rotation counterclockwise),  from 'z' to 'e' (5 clockwise rotations),  from 'e' to 'u' (10 rotations counterclockwise),  from 'u' to 's' (2 counterclockwise rotations).  In total, 1 + 5 + 10 + 2 = 18 rotations are required.


Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.One day Petya was delivered a string s, containing only digits. He needs to find a string that represents a lucky number without leading zeroes, is not empty, is contained in s as a substring the maximum number of times.Among all the strings for which the three conditions given above are fulfilled, Petya only needs the lexicographically minimum one. Find this string for Petya.

The single line contains a non-empty string s whose length can range from 1 to 50, inclusive. The string only contains digits. The string can contain leading zeroes.

In the only line print the answer to Petya's problem. If the sought string does not exist, print "-1" (without quotes).

NoteThe lexicographical comparison of strings is performed by the < operator in the modern programming languages. String x is lexicographically less than string y either if x is a prefix of y, or exists such i (1 ≤ i ≤ min(|x|, |y|)), that xi < yi and for any j (1 ≤ j < i) xj = yj. Here |a| denotes the length of string a.In the first sample three conditions are fulfilled for strings "4", "7" and "47". The lexicographically minimum one is "4".In the second sample s has no substrings which are lucky numbers.In the third sample the three conditions are only fulfilled for string "7".


You are given a positive integer $$$n$$$, written without leading zeroes (for example, the number 04 is incorrect). In one operation you can delete any digit of the given integer so that the result remains a positive integer without leading zeros.Determine the minimum number of operations that you need to consistently apply to the given integer $$$n$$$ to make from it the square of some positive integer or report that it is impossible.An integer $$$x$$$ is the square of some positive integer if and only if $$$x=y^2$$$ for some positive integer $$$y$$$.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^{9}$$$). The number is given without leading zeroes.

If it is impossible to make the square of some positive integer from $$$n$$$, print -1. In the other case, print the minimal number of operations required to do it.

NoteIn the first example we should delete from $$$8314$$$ the digits $$$3$$$ and $$$4$$$. After that $$$8314$$$ become equals to $$$81$$$, which is the square of the integer $$$9$$$.In the second example the given $$$625$$$ is the square of the integer $$$25$$$, so you should not delete anything. In the third example it is impossible to make the square from $$$333$$$, so the answer is -1.


Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - k;k] (i.e. one integer among  - k,  - k + 1,  - k + 2, ...,  - 2,  - 1, 0, 1, 2, ..., k - 1, k) and add them to their current scores. The game has exactly t turns. Memory and Lexa, however, are not good at this game, so they both always get a random integer at their turn.Memory wonders how many possible games exist such that he ends with a strictly higher score than Lexa. Two games are considered to be different if in at least one turn at least one player gets different score. There are (2k + 1)2t games in total. Since the answer can be very large, you should print it modulo 109 + 7. Please solve this problem for Memory.

The first and only line of input contains the four integers a, b, k, and t (1 ≤ a, b ≤ 100, 1 ≤ k ≤ 1000, 1 ≤ t ≤ 100) — the amount Memory and Lexa start with, the number k, and the number of turns respectively.

Print the number of possible games satisfying the conditions modulo 1 000 000 007 (109 + 7) in one line.

NoteIn the first sample test, Memory starts with 1 and Lexa starts with 2. If Lexa picks  - 2, Memory can pick 0, 1, or 2 to win. If Lexa picks  - 1, Memory can pick 1 or 2 to win. If Lexa picks 0, Memory can pick 2 to win. If Lexa picks 1 or 2, Memory cannot win. Thus, there are 3 + 2 + 1 = 6 possible games in which Memory wins.


Imp is watching a documentary about cave painting.  Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number n by all integers i from 1 to k. Unfortunately, there are too many integers to analyze for Imp.Imp wants you to check whether all these remainders are distinct. Formally, he wants to check, if all , 1 ≤ i ≤ k, are distinct, i. e. there is no such pair (i, j) that:   1 ≤ i < j ≤ k,  , where  is the remainder of division x by y.

The only line contains two integers n, k (1 ≤ n, k ≤ 1018).

Print "Yes", if all the remainders are distinct, and "No" otherwise. You can print each letter in arbitrary case (lower or upper).

NoteIn the first sample remainders modulo 1 and 4 coincide.


Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer m. What is the minimal number of moves making him climb to the top of the stairs that satisfies his condition?

The single line contains two space separated integers n, m (0 < n ≤ 10000, 1 < m ≤ 10).

Print a single integer — the minimal number of moves being a multiple of m. If there is no way he can climb satisfying condition print  - 1 instead.

NoteFor the first sample, Dreamoon could climb in 6 moves with following sequence of steps: {2, 2, 2, 2, 1, 1}.For the second sample, there are only three valid sequence of steps {2, 1}, {1, 2}, {1, 1, 1} with 2, 2, and 3 steps respectively. All these numbers are not multiples of 5.


Nick likes strings very much, he likes to rotate them, sort them, rearrange characters within a string... Once he wrote a random string of characters a, b, c on a piece of paper and began to perform the following operations:   to take two adjacent characters and replace the second character with the first one,  to take two adjacent characters and replace the first character with the second one To understand these actions better, let's take a look at a string «abc». All of the following strings can be obtained by performing one of the described operations on «abc»: «bbc», «abb», «acc». Let's denote the frequency of a character for each of the characters a, b and c as the number of occurrences of this character in the string. For example, for string «abc»: |a| = 1, |b| = 1, |c| = 1, and for string «bbc»: |a| = 0, |b| = 2, |c| = 1. While performing the described operations, Nick sometimes got balanced strings. Let's say that a string is balanced, if the frequencies of each character differ by at most 1. That is  - 1 ≤ |a| - |b| ≤ 1,  - 1 ≤ |a| - |c| ≤ 1 и  - 1 ≤ |b| - |c| ≤ 1. Would you help Nick find the number of different balanced strings that can be obtained by performing the operations described above, perhaps multiple times, on the given string s. This number should be calculated modulo 51123987.

The first line contains integer n (1 ≤ n ≤ 150) — the length of the given string s. Next line contains the given string s. The initial string can be balanced as well, in this case it should be counted too. The given string s consists only of characters a, b and c.

Output the only number — the number of different balanced strings that can be obtained by performing the described operations, perhaps multiple times, on the given string s, modulo 51123987.

NoteIn the first sample it is possible to get 51 different strings through the described operations, but only 7 of them are balanced: «abca», «bbca», «bcca», «bcaa», «abcc», «abbc», «aabc». In the second sample: «abbc», «aabc», «abcc». In the third sample there is only one balanced string — «ab» itself.


We all know that GukiZ often plays with arrays. Now he is thinking about this problem: how many arrays a, of length n, with non-negative elements strictly less then 2l meet the following condition: ? Here operation  means bitwise AND (in Pascal it is equivalent to and, in C/C++/Java/Python it is equivalent to &), operation  means bitwise OR (in Pascal it is equivalent to , in C/C++/Java/Python it is equivalent to |). Because the answer can be quite large, calculate it modulo m. This time GukiZ hasn't come up with solution, and needs you to help him!

First and the only line of input contains four integers n, k, l, m (2 ≤ n ≤ 1018, 0 ≤ k ≤ 1018, 0 ≤ l ≤ 64, 1 ≤ m ≤ 109 + 7).

In the single line print the number of arrays satisfying the condition above modulo m.

NoteIn the first sample, satisfying arrays are {1, 1}, {3, 1}, {1, 3}.In the second sample, only satisfying array is {1, 1}.In the third sample, satisfying arrays are {0, 3, 3}, {1, 3, 2}, {1, 3, 3}, {2, 3, 1}, {2, 3, 3}, {3, 3, 0}, {3, 3, 1}, {3, 3, 2}, {3, 3, 3}.


Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels!There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle... Everybody was upset. The beautiful Belle was upset, so was the Beast, so was Lumiere the candlestick. But the worst thing was that Cogsworth was upset. Cogsworth is not a human, but is the mantel clock, which was often used as an alarm clock.Due to Cogsworth's frustration all the inhabitants of the castle were in trouble: now they could not determine when it was time to drink morning tea, and when it was time for an evening stroll. Fortunately, deep in the basement are lying digital clock showing the time in the format HH:MM. Now the residents of the castle face a difficult task. They should turn Cogsworth's hour and minute mustache hands in such a way, that Cogsworth began to show the correct time. Moreover they need to find turn angles in degrees for each mustache hands. The initial time showed by Cogsworth is 12:00.You can only rotate the hands forward, that is, as is shown in the picture:   As since there are many ways too select such angles because of full rotations, choose the smallest angles in the right (non-negative) direction.Note that Cogsworth's hour and minute mustache hands move evenly and continuously. Hands are moving independently, so when turning one hand the other hand remains standing still.

The only line of input contains current time according to the digital clock, formatted as HH:MM (00 ≤ HH ≤ 23, 00 ≤ MM ≤ 59). The mantel clock initially shows 12:00. Pretests contain times of the beginning of some morning TV programs of the Channel One Russia.

Print two numbers x and y — the angles of turning the hour and minute hands, respectively (0 ≤ x, y < 360). The absolute or relative error in the answer should not exceed 10 - 9.

NoteA note to the second example: the hour hand will be positioned exactly in the middle, between 4 and 5.


You are given a square board, consisting of $$$n$$$ rows and $$$n$$$ columns. Each tile in it should be colored either white or black.Let's call some coloring beautiful if each pair of adjacent rows are either the same or different in every position. The same condition should be held for the columns as well.Let's call some coloring suitable if it is beautiful and there is no rectangle of the single color, consisting of at least $$$k$$$ tiles.Your task is to count the number of suitable colorings of the board of the given size.Since the answer can be very large, print it modulo $$$998244353$$$.

A single line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 500$$$, $$$1 \le k \le n^2$$$) — the number of rows and columns of the board and the maximum number of tiles inside the rectangle of the single color, respectively.

Print a single integer — the number of suitable colorings of the board of the given size modulo $$$998244353$$$.

NoteBoard of size $$$1 \times 1$$$ is either a single black tile or a single white tile. Both of them include a rectangle of a single color, consisting of $$$1$$$ tile.Here are the beautiful colorings of a board of size $$$2 \times 2$$$ that don't include rectangles of a single color, consisting of at least $$$3$$$ tiles:  The rest of beautiful colorings of a board of size $$$2 \times 2$$$ are the following:


For an array of integers $$$a$$$, let's define $$$|a|$$$ as the number of elements in it.Let's denote two functions: $$$F(a, k)$$$ is a function that takes an array of integers $$$a$$$ and a positive integer $$$k$$$. The result of this function is the array containing $$$|a|$$$ first elements of the array that you get by replacing each element of $$$a$$$ with exactly $$$k$$$ copies of that element.For example, $$$F([2, 2, 1, 3, 5, 6, 8], 2)$$$ is calculated as follows: first, you replace each element of the array with $$$2$$$ copies of it, so you obtain $$$[2, 2, 2, 2, 1, 1, 3, 3, 5, 5, 6, 6, 8, 8]$$$. Then, you take the first $$$7$$$ elements of the array you obtained, so the result of the function is $$$[2, 2, 2, 2, 1, 1, 3]$$$. $$$G(a, x, y)$$$ is a function that takes an array of integers $$$a$$$ and two different integers $$$x$$$ and $$$y$$$. The result of this function is the array $$$a$$$ with every element equal to $$$x$$$ replaced by $$$y$$$, and every element equal to $$$y$$$ replaced by $$$x$$$.For example, $$$G([1, 1, 2, 3, 5], 3, 1) = [3, 3, 2, 1, 5]$$$.An array $$$a$$$ is a parent of the array $$$b$$$ if:  either there exists a positive integer $$$k$$$ such that $$$F(a, k) = b$$$;  or there exist two different integers $$$x$$$ and $$$y$$$ such that $$$G(a, x, y) = b$$$. An array $$$a$$$ is an ancestor of the array $$$b$$$ if there exists a finite sequence of arrays $$$c_0, c_1, \dots, c_m$$$ ($$$m \ge 0$$$) such that $$$c_0$$$ is $$$a$$$, $$$c_m$$$ is $$$b$$$, and for every $$$i \in [1, m]$$$, $$$c_{i-1}$$$ is a parent of $$$c_i$$$.And now, the problem itself.You are given two integers $$$n$$$ and $$$k$$$. Your goal is to construct a sequence of arrays $$$s_1, s_2, \dots, s_m$$$ in such a way that:  every array $$$s_i$$$ contains exactly $$$n$$$ elements, and all elements are integers from $$$1$$$ to $$$k$$$;  for every array $$$a$$$ consisting of exactly $$$n$$$ integers from $$$1$$$ to $$$k$$$, the sequence contains at least one array $$$s_i$$$ such that $$$s_i$$$ is an ancestor of $$$a$$$. Print the minimum number of arrays in such sequence.

The only line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n, k \le 2 \cdot 10^5$$$).

Print one integer — the minimum number of elements in a sequence of arrays meeting the constraints. Since the answer can be large, output it modulo $$$998244353$$$.


Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers represents how many groups of black squares there are in corresponding row or column, and the integers themselves represents the number of consecutive black squares in corresponding group (you can find more detailed explanation in Wikipedia https://en.wikipedia.org/wiki/Japanese_crossword).Adaltik decided that the general case of japanese crossword is too complicated and drew a row consisting of n squares (e.g. japanese crossword sized 1 × n), which he wants to encrypt in the same way as in japanese crossword.    The example of encrypting of a single row of japanese crossword. Help Adaltik find the numbers encrypting the row he drew.

The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the length of the row. The second line of the input contains a single string consisting of n characters 'B' or 'W', ('B' corresponds to black square, 'W' — to white square in the row that Adaltik drew).

The first line should contain a single integer k — the number of integers encrypting the row, e.g. the number of groups of black squares in the row. The second line should contain k integers, encrypting the row, e.g. corresponding to sizes of groups of consecutive black squares in the order from left to right.

NoteThe last sample case correspond to the picture in the statement.


So nearly half of the winter is over and Maria is dreaming about summer. She's fed up with skates and sleds, she was dreaming about Hopscotch all night long. It's a very popular children's game. The game field, the court, looks as is shown in the figure (all blocks are square and are numbered from bottom to top, blocks in the same row are numbered from left to right). Let us describe the hopscotch with numbers that denote the number of squares in the row, staring from the lowest one: 1-1-2-1-2-1-2-(1-2)..., where then the period is repeated (1-2).  The coordinate system is defined as shown in the figure. Side of all the squares are equal and have length a.Maria is a very smart and clever girl, and she is concerned with quite serious issues: if she throws a stone into a point with coordinates (x, y), then will she hit some square? If the answer is positive, you are also required to determine the number of the square.It is believed that the stone has fallen into the square if it is located strictly inside it. In other words a stone that has fallen on the square border is not considered a to hit a square.

The only input line contains three integers: a, x, y, where a (1 ≤ a ≤ 100) is the side of the square, x and y ( - 106 ≤ x ≤ 106, 0 ≤ y ≤ 106) are coordinates of the stone.

Print the number of the square, inside which the stone fell. If the stone is on a border of some stone or outside the court, print "-1" without the quotes.


As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase English letters.Mu-mu's enemy Kashtanka wants to unlock Mu-mu's phone to steal some sensible information, but it can only bark n distinct words, each of which can be represented as a string of two lowercase English letters. Kashtanka wants to bark several words (not necessarily distinct) one after another to pronounce a string containing the password as a substring. Tell if it's possible to unlock the phone in this way, or not.

The first line contains two lowercase English letters — the password on the phone. The second line contains single integer n (1 ≤ n ≤ 100) — the number of words Kashtanka knows. The next n lines contain two lowercase English letters each, representing the words Kashtanka knows. The words are guaranteed to be distinct.

Print "YES" if Kashtanka can bark several words in a line forming a string containing the password, and "NO" otherwise. You can print each letter in arbitrary case (upper or lower).

NoteIn the first example the password is "ya", and Kashtanka can bark "oy" and then "ah", and then "ha" to form the string "oyahha" which contains the password. So, the answer is "YES".In the second example Kashtanka can't produce a string containing password as a substring. Note that it can bark "ht" and then "tp" producing "http", but it doesn't contain the password "hp" as a substring.In the third example the string "hahahaha" contains "ah" as a substring.


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

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

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

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


You are given an array of $$$n$$$ integers: $$$a_1, a_2, \ldots, a_n$$$. Your task is to find some non-zero integer $$$d$$$ ($$$-10^3 \leq d \leq 10^3$$$) such that, after each number in the array is divided by $$$d$$$, the number of positive numbers that are presented in the array is greater than or equal to half of the array size (i.e., at least $$$\lceil\frac{n}{2}\rceil$$$). Note that those positive numbers do not need to be an integer (e.g., a $$$2.5$$$ counts as a positive number). If there are multiple values of $$$d$$$ that satisfy the condition, you may print any of them. In case that there is no such $$$d$$$, print a single integer $$$0$$$.Recall that $$$\lceil x \rceil$$$ represents the smallest integer that is not less than $$$x$$$ and that zero ($$$0$$$) is neither positive nor negative.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the array. The second line contains $$$n$$$ space-separated integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-10^3 \le a_i \le 10^3$$$).

Print one integer $$$d$$$ ($$$-10^3 \leq d \leq 10^3$$$ and $$$d \neq 0$$$) that satisfies the given condition. If there are multiple values of $$$d$$$ that satisfy the condition, you may print any of them. In case that there is no such $$$d$$$, print a single integer $$$0$$$.

NoteIn the first sample, $$$n = 5$$$, so we need at least $$$\lceil\frac{5}{2}\rceil = 3$$$ positive numbers after division. If $$$d = 4$$$, the array after division is $$$[2.5, 0, -1.75, 0.5, 1.5]$$$, in which there are $$$3$$$ positive numbers (namely: $$$2.5$$$, $$$0.5$$$, and $$$1.5$$$).In the second sample, there is no valid $$$d$$$, so $$$0$$$ should be printed.


You are given a chessboard of size 1 × n. It is guaranteed that n is even. The chessboard is painted like this: "BWBW...BW".Some cells of the board are occupied by the chess pieces. Each cell contains no more than one chess piece. It is known that the total number of pieces equals to .In one step you can move one of the pieces one cell to the left or to the right. You cannot move pieces beyond the borders of the board. You also cannot move pieces to the cells that are already occupied.Your task is to place all the pieces in the cells of the same color using the minimum number of moves (all the pieces must occupy only the black cells or only the white cells after all the moves are made).

The first line of the input contains one integer n (2 ≤ n ≤ 100, n is even) — the size of the chessboard.  The second line of the input contains  integer numbers  (1 ≤ pi ≤ n) — initial positions of the pieces. It is guaranteed that all the positions are distinct.

Print one integer — the minimum number of moves you have to make to place all the pieces in the cells of the same color.

NoteIn the first example the only possible strategy is to move the piece at the position 6 to the position 5 and move the piece at the position 2 to the position 3. Notice that if you decide to place the pieces in the white cells the minimum number of moves will be 3.In the second example the possible strategy is to move  in 4 moves, then  in 3 moves,  in 2 moves and  in 1 move.


Stepan is a very experienced olympiad participant. He has n cups for Physics olympiads and m cups for Informatics olympiads. Each cup is characterized by two parameters — its significance ci and width wi.Stepan decided to expose some of his cups on a shelf with width d in such a way, that:  there is at least one Physics cup and at least one Informatics cup on the shelf,  the total width of the exposed cups does not exceed d,  from each subjects (Physics and Informatics) some of the most significant cups are exposed (i. e. if a cup for some subject with significance x is exposed, then all the cups for this subject with significance greater than x must be exposed too). Your task is to determine the maximum possible total significance, which Stepan can get when he exposes cups on the shelf with width d, considering all the rules described above. The total significance is the sum of significances of all the exposed cups.

The first line contains three integers n, m and d (1 ≤ n, m ≤ 100 000, 1 ≤ d ≤ 109) — the number of cups for Physics olympiads, the number of cups for Informatics olympiads and the width of the shelf. Each of the following n lines contains two integers ci and wi (1 ≤ ci, wi ≤ 109) — significance and width of the i-th cup for Physics olympiads. Each of the following m lines contains two integers cj and wj (1 ≤ cj, wj ≤ 109) — significance and width of the j-th cup for Informatics olympiads.

Print the maximum possible total significance, which Stepan can get exposing cups on the shelf with width d, considering all the rules described in the statement. If there is no way to expose cups on the shelf, then print 0.

NoteIn the first example Stepan has only one Informatics cup which must be exposed on the shelf. Its significance equals 3 and width equals 2, so after Stepan exposes it, the width of free space on the shelf becomes equal to 6. Also, Stepan must expose the second Physics cup (which has width 5), because it is the most significant cup for Physics (its significance equals 5). After that Stepan can not expose more cups on the shelf, because there is no enough free space. Thus, the maximum total significance of exposed cups equals to 8.


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 50$$$), $$$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 50, 1 \le T \le 2500$$$) — 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 50, 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).


Tonio has a keyboard with only two letters, "V" and "K".One day, he has typed out a string s with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times "VK" can appear as a substring (i. e. a letter "K" right after a letter "V") in the resulting string.

The first line will contain a string s consisting only of uppercase English letters "V" and "K" with length not less than 1 and not greater than 100.

Output a single integer, the maximum number of times "VK" can appear as a substring of the given string after changing at most one character.

NoteFor the first case, we do not change any letters. "VK" appears once, which is the maximum number of times it could appear.For the second case, we can change the second character from a "V" to a "K". This will give us the string "VK". This has one occurrence of the string "VK" as a substring.For the fourth case, we can change the fourth character from a "K" to a "V". This will give us the string "VKKVKKKKKKVVVVVVVVVK". This has three occurrences of the string "VK" as a substring. We can check no other moves can give us strictly more occurrences.


Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equal to the total weight of the apples given to Ogiso Setsuna.But unfortunately Kitahara Haruki doesn't have a knife right now, so he cannot split any apple into some parts. Please, tell him: is it possible to divide all the apples in a fair way between his friends?

The first line contains an integer n (1 ≤ n ≤ 100) — the number of apples. The second line contains n integers w1, w2, ..., wn (wi = 100 or wi = 200), where wi is the weight of the i-th apple.

In a single line print "YES" (without the quotes) if it is possible to divide all the apples between his friends. Otherwise print "NO" (without the quotes).

NoteIn the first test sample Kitahara Haruki can give the first and the last apple to Ogiso Setsuna and the middle apple to Touma Kazusa.


Rock... Paper!After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.A positive integer n is decided first. Both Koyomi and Karen independently choose n distinct positive integers, denoted by x1, x2, ..., xn and y1, y2, ..., yn respectively. They reveal their sequences, and repeat until all of 2n integers become distinct, which is the only final state to be kept and considered.Then they count the number of ordered pairs (i, j) (1 ≤ i, j ≤ n) such that the value xi xor yj equals to one of the 2n integers. Here xor means the bitwise exclusive or operation on two integers, and is denoted by operators ^ and/or xor in most programming languages.Karen claims a win if the number of such pairs is even, and Koyomi does otherwise. And you're here to help determine the winner of their latest game.

The first line of input contains a positive integer n (1 ≤ n ≤ 2 000) — the length of both sequences. The second line contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 2·106) — the integers finally chosen by Koyomi. The third line contains n space-separated integers y1, y2, ..., yn (1 ≤ yi ≤ 2·106) — the integers finally chosen by Karen. Input guarantees that the given 2n integers are pairwise distinct, that is, no pair (i, j) (1 ≤ i, j ≤ n) exists such that one of the following holds: xi = yj; i ≠ j and xi = xj; i ≠ j and yi = yj.

Output one line — the name of the winner, that is, "Koyomi" or "Karen" (without quotes). Please be aware of the capitalization.

NoteIn the first example, there are 6 pairs satisfying the constraint: (1, 1), (1, 2), (2, 1), (2, 3), (3, 2) and (3, 3). Thus, Karen wins since 6 is an even number.In the second example, there are 16 such pairs, and Karen wins again.


A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly x times.The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.

The first line contains integers n and m (1 ≤ n, m ≤ 5000). The second line contains integer x (1 ≤ x ≤ 109).

Print how many squares will be painted exactly x times.


The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations. Help the Little Elephant to find the described number.

A single line contains a single integer x (1 ≤ x ≤ 109).

In a single line print an integer — the answer to the problem.


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

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

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


In the city of Saint Petersburg, a day lasts for $$$2^{100}$$$ minutes. From the main station of Saint Petersburg, a train departs after $$$1$$$ minute, $$$4$$$ minutes, $$$16$$$ minutes, and so on; in other words, the train departs at time $$$4^k$$$ for each integer $$$k \geq 0$$$. Team BowWow has arrived at the station at the time $$$s$$$ and it is trying to count how many trains have they missed; in other words, the number of trains that have departed strictly before time $$$s$$$. For example if $$$s = 20$$$, then they missed trains which have departed at $$$1$$$, $$$4$$$ and $$$16$$$. As you are the only one who knows the time, help them!Note that the number $$$s$$$ will be given you in a binary representation without leading zeroes.

The first line contains a single binary number $$$s$$$ ($$$0 \leq s < 2^{100}$$$) without leading zeroes.

Output a single number — the number of trains which have departed strictly before the time $$$s$$$.

NoteIn the first example $$$100000000_2 = 256_{10}$$$, missed trains have departed at $$$1$$$, $$$4$$$, $$$16$$$ and $$$64$$$.In the second example $$$101_2 = 5_{10}$$$, trains have departed at $$$1$$$ and $$$4$$$.The third example is explained in the statements.


You are given an integer $$$n$$$ from $$$1$$$ to $$$10^{18}$$$ without leading zeroes.In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes.What is the minimum number of moves you have to make to obtain a number that is divisible by $$$25$$$? Print -1 if it is impossible to obtain a number that is divisible by $$$25$$$.

The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^{18}$$$). It is guaranteed that the first (left) digit of the number $$$n$$$ is not a zero.

If it is impossible to obtain a number that is divisible by $$$25$$$, print -1. Otherwise print the minimum number of moves required to obtain such number. Note that you can swap only adjacent digits in the given number.

NoteIn the first example one of the possible sequences of moves is 5071 $$$\rightarrow$$$ 5701 $$$\rightarrow$$$ 7501 $$$\rightarrow$$$ 7510 $$$\rightarrow$$$ 7150.


You are given an alphabet consisting of n letters, your task is to make a string of the maximum possible length so that the following conditions are satisfied:   the i-th letter occurs in the string no more than ai times;  the number of occurrences of each letter in the string must be distinct for all the letters that occurred in the string at least once.

The first line of the input contains a single integer n (2  ≤  n  ≤  26) — the number of letters in the alphabet. The next line contains n integers ai (1 ≤ ai ≤ 109) — i-th of these integers gives the limitation on the number of occurrences of the i-th character in the string.

Print a single integer — the maximum length of the string that meets all the requirements.

NoteFor convenience let's consider an alphabet consisting of three letters: "a", "b", "c". In the first sample, some of the optimal strings are: "cccaabbccbb", "aabcbcbcbcb". In the second sample some of the optimal strings are: "acc", "cbc".


Note that the memory limit in this problem is lower than in others.You have a vertical strip with $$$n$$$ cells, numbered consecutively from $$$1$$$ to $$$n$$$ from top to bottom.You also have a token that is initially placed in cell $$$n$$$. You will move the token up until it arrives at cell $$$1$$$.Let the token be in cell $$$x > 1$$$ at some moment. One shift of the token can have either of the following kinds:   Subtraction: you choose an integer $$$y$$$ between $$$1$$$ and $$$x-1$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$x - y$$$.  Floored division: you choose an integer $$$z$$$ between $$$2$$$ and $$$x$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$\lfloor \frac{x}{z} \rfloor$$$ ($$$x$$$ divided by $$$z$$$ rounded down). Find the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$ using one or more shifts, and print it modulo $$$m$$$. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).

The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 4 \cdot 10^6$$$; $$$10^8 < m < 10^9$$$; $$$m$$$ is a prime number) — the length of the strip and the modulo.

Print the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$, modulo $$$m$$$.

NoteIn the first test, there are three ways to move the token from cell $$$3$$$ to cell $$$1$$$ in one shift: using subtraction of $$$y = 2$$$, or using division by $$$z = 2$$$ or $$$z = 3$$$.There are also two ways to move the token from cell $$$3$$$ to cell $$$1$$$ via cell $$$2$$$: first subtract $$$y = 1$$$, and then either subtract $$$y = 1$$$ again or divide by $$$z = 2$$$.Therefore, there are five ways in total.


The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Taylor to find that year.Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100 (https://en.wikipedia.org/wiki/Leap_year).

The only line contains integer y (1000 ≤ y < 100'000) — the year of the calendar.

Print the only integer y' — the next year after y when the calendar will be the same. Note that you should find the first year after y with the same calendar.

NoteToday is Monday, the 13th of June, 2016.


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

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

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

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


One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:—Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.—No problem! — said Bob and immediately gave her an answer.Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.

The first line contains one integer n (0 ≤ n ≤ 109) without leading zeroes. The second lines contains one integer m (0 ≤ m ≤ 109) — Bob's answer, possibly with leading zeroes.

Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.


Arpa is researching the Mexican wave.There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0.   At time 1, the first spectator stands.  At time 2, the second spectator stands.  ...  At time k, the k-th spectator stands.  At time k + 1, the (k + 1)-th spectator stands and the first spectator sits.  At time k + 2, the (k + 2)-th spectator stands and the second spectator sits.  ...  At time n, the n-th spectator stands and the (n - k)-th spectator sits.  At time n + 1, the (n + 1 - k)-th spectator sits.  ...  At time n + k, the n-th spectator sits. Arpa wants to know how many spectators are standing at time t.

The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).

Print single integer: how many spectators are standing at time t.

NoteIn the following a sitting spectator is represented as -, a standing spectator is represented as ^.  At t = 0  ----------  number of standing spectators = 0.  At t = 1  ^---------  number of standing spectators = 1.  At t = 2  ^^--------  number of standing spectators = 2.  At t = 3  ^^^-------  number of standing spectators = 3.  At t = 4  ^^^^------  number of standing spectators = 4.  At t = 5  ^^^^^-----  number of standing spectators = 5.  At t = 6  -^^^^^----  number of standing spectators = 5.  At t = 7  --^^^^^---  number of standing spectators = 5.  At t = 8  ---^^^^^--  number of standing spectators = 5.  At t = 9  ----^^^^^-  number of standing spectators = 5.  At t = 10 -----^^^^^  number of standing spectators = 5.  At t = 11 ------^^^^  number of standing spectators = 4.  At t = 12 -------^^^  number of standing spectators = 3.  At t = 13 --------^^  number of standing spectators = 2.  At t = 14 ---------^  number of standing spectators = 1.  At t = 15 ----------  number of standing spectators = 0.


A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.Let's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 ≤ i ≤ n) such that pi = i.Your task is to count the number of almost identity permutations for given numbers n and k.

The first line contains two integers n and k (4 ≤ n ≤ 1000, 1 ≤ k ≤ 4).

Print the number of almost identity permutations for given n and k.


Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there.At a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results, will get a diploma of the first, second or third degree. Thus, each student will receive exactly one diploma.They also decided that there must be given at least min1 and at most max1 diplomas of the first degree, at least min2 and at most max2 diplomas of the second degree, and at least min3 and at most max3 diplomas of the third degree.After some discussion it was decided to choose from all the options of distributing diplomas satisfying these limitations the one that maximizes the number of participants who receive diplomas of the first degree. Of all these options they select the one which maximizes the number of the participants who receive diplomas of the second degree. If there are multiple of these options, they select the option that maximizes the number of diplomas of the third degree.Choosing the best option of distributing certificates was entrusted to Ilya, one of the best programmers of Berland. However, he found more important things to do, so it is your task now to choose the best option of distributing of diplomas, based on the described limitations.It is guaranteed that the described limitations are such that there is a way to choose such an option of distributing diplomas that all n participants of the Olympiad will receive a diploma of some degree.

The first line of the input contains a single integer n (3 ≤ n ≤ 3·106) — the number of schoolchildren who will participate in the Olympiad. The next line of the input contains two integers min1 and max1 (1 ≤ min1 ≤ max1 ≤ 106) — the minimum and maximum limits on the number of diplomas of the first degree that can be distributed. The third line of the input contains two integers min2 and max2 (1 ≤ min2 ≤ max2 ≤ 106) — the minimum and maximum limits on the number of diplomas of the second degree that can be distributed.  The next line of the input contains two integers min3 and max3 (1 ≤ min3 ≤ max3 ≤ 106) — the minimum and maximum limits on the number of diplomas of the third degree that can be distributed.  It is guaranteed that min1 + min2 + min3 ≤ n ≤ max1 + max2 + max3.

In the first line of the output print three numbers, showing how many diplomas of the first, second and third degree will be given to students in the optimal variant of distributing diplomas. The optimal variant of distributing diplomas is the one that maximizes the number of students who receive diplomas of the first degree. Of all the suitable options, the best one is the one which maximizes the number of participants who receive diplomas of the second degree. If there are several of these options, the best one is the one that maximizes the number of diplomas of the third degree.


Hasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are $$$p$$$ players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-scorers will be declared as the winner randomly with equal probability.They have just finished the game and now are waiting for the result. But there's a tiny problem! The judges have lost the paper of scores! Fortunately they have calculated sum of the scores before they get lost and also for some of the players they have remembered a lower bound on how much they scored. However, the information about the bounds is private, so Hasan only got to know his bound.According to the available data, he knows that his score is at least $$$r$$$ and sum of the scores is $$$s$$$.Thus the final state of the game can be represented in form of sequence of $$$p$$$ integers $$$a_1, a_2, \dots, a_p$$$ ($$$0 \le a_i$$$) — player's scores. Hasan is player number $$$1$$$, so $$$a_1 \ge r$$$. Also $$$a_1 + a_2 + \dots + a_p = s$$$. Two states are considered different if there exists some position $$$i$$$ such that the value of $$$a_i$$$ differs in these states. Once again, Hasan doesn't know the exact scores (he doesn't know his exact score as well). So he considers each of the final states to be equally probable to achieve.Help Hasan find the probability of him winning.It can be shown that it is in the form of $$$\frac{P}{Q}$$$ where $$$P$$$ and $$$Q$$$ are non-negative integers and $$$Q \ne 0$$$, $$$P \le Q$$$. Report the value of $$$P \cdot Q^{-1} \pmod {998244353}$$$.

The only line contains three integers $$$p$$$, $$$s$$$ and $$$r$$$ ($$$1 \le p \le 100$$$, $$$0 \le r \le s \le 5000$$$) — the number of players, the sum of scores of all players and Hasan's score, respectively.

Print a single integer — the probability of Hasan winning. It can be shown that it is in the form of $$$\frac{P}{Q}$$$ where $$$P$$$ and $$$Q$$$ are non-negative integers and $$$Q \ne 0$$$, $$$P \le Q$$$. Report the value of $$$P \cdot Q^{-1} \pmod {998244353}$$$.

NoteIn the first example Hasan can score $$$3$$$, $$$4$$$, $$$5$$$ or $$$6$$$ goals. If he scores $$$4$$$ goals or more than he scores strictly more than his only opponent. If he scores $$$3$$$ then his opponent also scores $$$3$$$ and Hasan has a probability of $$$\frac 1 2$$$ to win the game. Thus, overall he has the probability of $$$\frac 7 8$$$ to win.In the second example even Hasan's lower bound on goal implies him scoring more than any of his opponents. Thus, the resulting probability is $$$1$$$.


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
NEAT
Output
YES
Input
WORD
Output
NO
Input
CODER
Output
NO
Input
APRILFOOL
Output
NO
Input
AI
Output
YES
Input
JUROR
Output
YES
Input
YES
Output
NO


One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one!Why not make her own Codeforces, with blackjack and other really cool stuff? Many people will surely be willing to visit this splendid shrine of high culture.In Mainframe a standard pack of 52 cards is used to play blackjack. The pack contains cards of 13 values: 2, 3, 4, 5, 6, 7, 8, 9, 10, jacks, queens, kings and aces. Each value also exists in one of four suits: hearts, diamonds, clubs and spades. Also, each card earns some value in points assigned to it: cards with value from two to ten earn from 2 to 10 points, correspondingly. An ace can either earn 1 or 11, whatever the player wishes. The picture cards (king, queen and jack) earn 10 points. The number of points a card earns does not depend on the suit. The rules of the game are very simple. The player gets two cards, if the sum of points of those cards equals n, then the player wins, otherwise the player loses.The player has already got the first card, it's the queen of spades. To evaluate chances for victory, you should determine how many ways there are to get the second card so that the sum of points exactly equals n.

The only line contains n (1 ≤ n ≤ 25) — the required sum of points.

Print the numbers of ways to get the second card in the required way if the first card is the queen of spades.

NoteIn the first sample only four two's of different suits can earn the required sum of points.In the second sample we can use all tens, jacks, queens and kings; overall it's 15 cards, as the queen of spades (as any other card) is only present once in the pack of cards and it's already in use.In the third sample there is no card, that would add a zero to the current ten points.


Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers.Let's remember how Fibonacci numbers can be calculated. F0 = 0, F1 = 1, and all the next numbers are Fi = Fi - 2 + Fi - 1.So, Fibonacci numbers make a sequence of numbers: 0, 1, 1, 2, 3, 5, 8, 13, ...If you haven't run away from the PC in fear, you have to help the virus. Your task is to divide given Fibonacci number n by three not necessary different Fibonacci numbers or say that it is impossible.

The input contains of a single integer n (0 ≤ n < 109) — the number that should be represented by the rules described above. It is guaranteed that n is a Fibonacci number.

Output three required numbers: a, b and c. If there is no answer for the test you have to print "I'm too stupid to solve this problem" without the quotes. If there are multiple answers, print any of them.


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.


Polycarp is preparing the first programming contest for robots. There are $$$n$$$ problems in it, and a lot of robots are going to participate in it. Each robot solving the problem $$$i$$$ gets $$$p_i$$$ points, and the score of each robot in the competition is calculated as the sum of $$$p_i$$$ over all problems $$$i$$$ solved by it. For each problem, $$$p_i$$$ is an integer not less than $$$1$$$.Two corporations specializing in problem-solving robot manufacturing, "Robo-Coder Inc." and "BionicSolver Industries", are going to register two robots (one for each corporation) for participation as well. Polycarp knows the advantages and flaws of robots produced by these companies, so, for each problem, he knows precisely whether each robot will solve it during the competition. Knowing this, he can try predicting the results — or manipulating them. For some reason (which absolutely cannot involve bribing), Polycarp wants the "Robo-Coder Inc." robot to outperform the "BionicSolver Industries" robot in the competition. Polycarp wants to set the values of $$$p_i$$$ in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot. However, if the values of $$$p_i$$$ will be large, it may look very suspicious — so Polycarp wants to minimize the maximum value of $$$p_i$$$ over all problems. Can you help Polycarp to determine the minimum possible upper bound on the number of points given for solving the problems?

The first line contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of problems. The second line contains $$$n$$$ integers $$$r_1$$$, $$$r_2$$$, ..., $$$r_n$$$ ($$$0 \le r_i \le 1$$$). $$$r_i = 1$$$ means that the "Robo-Coder Inc." robot will solve the $$$i$$$-th problem, $$$r_i = 0$$$ means that it won't solve the $$$i$$$-th problem. The third line contains $$$n$$$ integers $$$b_1$$$, $$$b_2$$$, ..., $$$b_n$$$ ($$$0 \le b_i \le 1$$$). $$$b_i = 1$$$ means that the "BionicSolver Industries" robot will solve the $$$i$$$-th problem, $$$b_i = 0$$$ means that it won't solve the $$$i$$$-th problem.

If "Robo-Coder Inc." robot cannot outperform the "BionicSolver Industries" robot by any means, print one integer $$$-1$$$. Otherwise, print the minimum possible value of $$$\max \limits_{i = 1}^{n} p_i$$$, if all values of $$$p_i$$$ are set in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot.

NoteIn the first example, one of the valid score assignments is $$$p = [3, 1, 3, 1, 1]$$$. Then the "Robo-Coder" gets $$$7$$$ points, the "BionicSolver" — $$$6$$$ points.In the second example, both robots get $$$0$$$ points, and the score distribution does not matter.In the third example, both robots solve all problems, so their points are equal.


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

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

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

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


You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x1, x2, ..., xk} (1 ≤ xi ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e.

The first line contains one integer n (1 ≤ n ≤ 22) — the size of the array. The second line contains n space-separated distinct integers a1, a2, ..., an (0 ≤ ai ≤ 109) — the elements of the array.

If there is no such array b, print -1. Otherwise in the only line print n space-separated integers b1, b2, ..., bn. Note that b must be a permutation of a. If there are multiple answers, print any of them.

NoteAn array x is a permutation of y, if we can shuffle elements of y such that it will coincide with x.Note that the empty subset and the subset containing all indices are not counted.


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.


At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle to Peter. Peter said that Bob's triangle is not right-angled, but is almost right-angled: the triangle itself is not right-angled, but it is possible to move one of the points exactly by distance 1 so, that all the coordinates remain integer, and the triangle become right-angled. Bob asks you to help him and find out if Peter tricks him. By the given coordinates of the triangle you should find out if it is right-angled, almost right-angled, or neither of these.

The first input line contains 6 space-separated integers x1, y1, x2, y2, x3, y3 — coordinates of the triangle's vertices. All the coordinates are integer and don't exceed 100 in absolute value. It's guaranteed that the triangle is nondegenerate, i.e. its total area is not zero.

If the given triangle is right-angled, output RIGHT, if it is almost right-angled, output ALMOST, and if it is neither of these, output NEITHER.


You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers.

The first line contains integers n and k — the number and digit capacity of numbers correspondingly (1 ≤ n, k ≤ 8). Next n lines contain k-digit positive integers. Leading zeroes are allowed both in the initial integers and the integers resulting from the rearranging of digits.

Print a single number: the minimally possible difference between the largest and the smallest number after the digits are rearranged in all integers by the same rule.

NoteIn the first sample, if we rearrange the digits in numbers as (3,1,4,2), then the 2-nd and the 4-th numbers will equal 5237 and 2537 correspondingly (they will be maximum and minimum for such order of digits).In the second sample, if we swap the second digits and the first ones, we get integers 100, 99 and 102.


Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give up. Having obtained an empty certificate from a local hospital, he is going to use his knowledge of local doctor's handwriting to make a counterfeit certificate of illness. However, after writing most of the certificate, Andrey suddenly discovered that doctor's signature is impossible to forge. Or is it?For simplicity, the signature is represented as an $$$n\times m$$$ grid, where every cell is either filled with ink or empty. Andrey's pen can fill a $$$3\times3$$$ square without its central cell if it is completely contained inside the grid, as shown below. xxxx.xxxx Determine whether is it possible to forge the signature on an empty $$$n\times m$$$ grid.

The first line of input contains two integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 1000$$$). Then $$$n$$$ lines follow, each contains $$$m$$$ characters. Each of the characters is either '.', representing an empty cell, or '#', representing an ink filled cell.

If Andrey can forge the signature, output "YES". Otherwise output "NO". You can print each letter in any case (upper or lower).

NoteIn the first sample Andrey can paint the border of the square with the center in $$$(2, 2)$$$.In the second sample the signature is impossible to forge.In the third sample Andrey can paint the borders of the squares with the centers in $$$(2, 2)$$$ and $$$(3, 2)$$$:   we have a clear paper: ............  use the pen with center at $$$(2, 2)$$$. ####.####...  use the pen with center at $$$(3, 2)$$$. ############ In the fourth sample Andrey can paint the borders of the squares with the centers in $$$(3, 3)$$$ and $$$(3, 5)$$$.


Polycarpus likes giving presents to Paraskevi. He has bought two chocolate bars, each of them has the shape of a segmented rectangle. The first bar is a1 × b1 segments large and the second one is a2 × b2 segments large.Polycarpus wants to give Paraskevi one of the bars at the lunch break and eat the other one himself. Besides, he wants to show that Polycarpus's mind and Paraskevi's beauty are equally matched, so the two bars must have the same number of squares.To make the bars have the same number of squares, Polycarpus eats a little piece of chocolate each minute. Each minute he does the following:  he either breaks one bar exactly in half (vertically or horizontally) and eats exactly a half of the bar,  or he chips of exactly one third of a bar (vertically or horizontally) and eats exactly a third of the bar. In the first case he is left with a half, of the bar and in the second case he is left with two thirds of the bar.Both variants aren't always possible, and sometimes Polycarpus cannot chip off a half nor a third. For example, if the bar is 16 × 23, then Polycarpus can chip off a half, but not a third. If the bar is 20 × 18, then Polycarpus can chip off both a half and a third. If the bar is 5 × 7, then Polycarpus cannot chip off a half nor a third.What is the minimum number of minutes Polycarpus needs to make two bars consist of the same number of squares? Find not only the required minimum number of minutes, but also the possible sizes of the bars after the process.

The first line of the input contains integers a1, b1 (1 ≤ a1, b1 ≤ 109) — the initial sizes of the first chocolate bar. The second line of the input contains integers a2, b2 (1 ≤ a2, b2 ≤ 109) — the initial sizes of the second bar. You can use the data of type int64 (in Pascal), long long (in С++), long (in Java) to process large integers (exceeding 231 - 1).

In the first line print m — the sought minimum number of minutes. In the second and third line print the possible sizes of the bars after they are leveled in m minutes. Print the sizes using the format identical to the input format. Print the sizes (the numbers in the printed pairs) in any order. The second line must correspond to the first bar and the third line must correspond to the second bar. If there are multiple solutions, print any of them. If there is no solution, print a single line with integer -1.


There are $$$n + 2$$$ towns located on a coordinate line, numbered from $$$0$$$ to $$$n + 1$$$. The $$$i$$$-th town is located at the point $$$i$$$.You build a radio tower in each of the towns $$$1, 2, \dots, n$$$ with probability $$$\frac{1}{2}$$$ (these events are independent). After that, you want to set the signal power on each tower to some integer from $$$1$$$ to $$$n$$$ (signal powers are not necessarily the same, but also not necessarily different). The signal from a tower located in a town $$$i$$$ with signal power $$$p$$$ reaches every city $$$c$$$ such that $$$|c - i| < p$$$.After building the towers, you want to choose signal powers in such a way that:  towns $$$0$$$ and $$$n + 1$$$ don't get any signal from the radio towers;  towns $$$1, 2, \dots, n$$$ get signal from exactly one radio tower each. For example, if $$$n = 5$$$, and you have built the towers in towns $$$2$$$, $$$4$$$ and $$$5$$$, you may set the signal power of the tower in town $$$2$$$ to $$$2$$$, and the signal power of the towers in towns $$$4$$$ and $$$5$$$ to $$$1$$$. That way, towns $$$0$$$ and $$$n + 1$$$ don't get the signal from any tower, towns $$$1$$$, $$$2$$$ and $$$3$$$ get the signal from the tower in town $$$2$$$, town $$$4$$$ gets the signal from the tower in town $$$4$$$, and town $$$5$$$ gets the signal from the tower in town $$$5$$$.Calculate the probability that, after building the towers, you will have a way to set signal powers to meet all constraints.

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

Print one integer — the probability that there will be a way to set signal powers so that all constraints are met, taken modulo $$$998244353$$$. Formally, the probability can be expressed as an irreducible fraction $$$\frac{x}{y}$$$. You have to print the value of $$$x \cdot y^{-1} \bmod 998244353$$$, where $$$y^{-1}$$$ is an integer such that $$$y \cdot y^{-1} \bmod 998244353 = 1$$$.

NoteThe real answer for the first example is $$$\frac{1}{4}$$$:  with probability $$$\frac{1}{4}$$$, the towers are built in both towns $$$1$$$ and $$$2$$$, so we can set their signal powers to $$$1$$$. The real answer for the second example is $$$\frac{1}{4}$$$:   with probability $$$\frac{1}{8}$$$, the towers are built in towns $$$1$$$, $$$2$$$ and $$$3$$$, so we can set their signal powers to $$$1$$$;  with probability $$$\frac{1}{8}$$$, only one tower in town $$$2$$$ is built, and we can set its signal power to $$$2$$$. The real answer for the third example is $$$\frac{5}{32}$$$. Note that even though the previous explanations used equal signal powers for all towers, it is not necessarily so. For example, if $$$n = 5$$$ and the towers are built in towns $$$2$$$, $$$4$$$ and $$$5$$$, you may set the signal power of the tower in town $$$2$$$ to $$$2$$$, and the signal power of the towers in towns $$$4$$$ and $$$5$$$ to $$$1$$$.


Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle.More formally, there are 3n gnomes sitting in a circle. Each gnome can have from 1 to 3 coins. Let's number the places in the order they occur in the circle by numbers from 0 to 3n - 1, let the gnome sitting on the i-th place have ai coins. If there is an integer i (0 ≤ i < n) such that ai + ai + n + ai + 2n ≠ 6, then Tanya is satisfied. Count the number of ways to choose ai so that Tanya is satisfied. As there can be many ways of distributing coins, print the remainder of this number modulo 109 + 7. Two ways, a and b, are considered distinct if there is index i (0 ≤ i < 3n), such that ai ≠ bi (that is, some gnome got different number of coins in these two ways).

A single line contains number n (1 ≤ n ≤ 105) — the number of the gnomes divided by three.

Print a single number — the remainder of the number of variants of distributing coins that satisfy Tanya modulo 109 + 7.

Note20 ways for n = 1 (gnome with index 0 sits on the top of the triangle, gnome 1 on the right vertex, gnome 2 on the left vertex):


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.


In problems on strings one often has to find a string with some particular properties. The problem authors were reluctant to waste time on thinking of a name for some string so they called it good. A string is good if it doesn't have palindrome substrings longer than or equal to d. You are given string s, consisting only of lowercase English letters. Find a good string t with length |s|, consisting of lowercase English letters, which is lexicographically larger than s. Of all such strings string t must be lexicographically minimum.We will call a non-empty string s[a ... b] = sasa + 1... sb (1 ≤ a ≤ b ≤ |s|) a substring of string s = s1s2... s|s|.A non-empty string s = s1s2... sn is called a palindrome if for all i from 1 to n the following fulfills: si = sn - i + 1. In other words, palindrome read the same in both directions.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 such strings are compared like their ASCII codes.

The first line contains integer d (1 ≤ d ≤ |s|). The second line contains a non-empty string s, its length is no more than 4·105 characters. The string consists of lowercase English letters.

Print the good string that lexicographically follows s, has the same length and consists of only lowercase English letters. If such string does not exist, print "Impossible" (without the quotes).


You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0.Write the program which finds the number of points in the intersection of two given sets.

The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive.

Print the number of points in the intersection or -1 if there are infinite number of points.


Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters.Let A be a set of positions in the string. Let's call it pretty if following conditions are met:  letters on positions from A in the string are all distinct and lowercase;  there are no uppercase letters in the string which are situated between positions from A (i.e. there is no such j that s[j] is an uppercase letter, and a1 < j < a2 for some a1 and a2 from A). Write a program that will determine the maximum number of elements in a pretty set of positions.

The first line contains a single integer n (1 ≤ n ≤ 200) — length of string s. The second line contains a string s consisting of lowercase and uppercase Latin letters.

Print maximum number of elements in pretty set of positions for string s.

NoteIn the first example the desired positions might be 6 and 8 or 7 and 8. Positions 6 and 7 contain letters 'a', position 8 contains letter 'b'. The pair of positions 1 and 8 is not suitable because there is an uppercase letter 'B' between these position.In the second example desired positions can be 7, 8 and 11. There are other ways to choose pretty set consisting of three elements.In the third example the given string s does not contain any lowercase letters, so the answer is 0.


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

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

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

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


Consider a playoff tournament where $$$2^n$$$ athletes compete. The athletes are numbered from $$$1$$$ to $$$2^n$$$.The tournament is held in $$$n$$$ stages. In each stage, the athletes are split into pairs in such a way that each athlete belongs exactly to one pair. In each pair, the athletes compete against each other, and exactly one of them wins. The winner of each pair advances to the next stage, the athlete who was defeated gets eliminated from the tournament.The pairs are formed as follows:  in the first stage, athlete $$$1$$$ competes against athlete $$$2$$$; $$$3$$$ competes against $$$4$$$; $$$5$$$ competes against $$$6$$$, and so on;  in the second stage, the winner of the match "$$$1$$$–$$$2$$$" competes against the winner of the match "$$$3$$$–$$$4$$$"; the winner of the match "$$$5$$$–$$$6$$$" competes against the winner of the match "$$$7$$$–$$$8$$$", and so on;  the next stages are held according to the same rules. When athletes $$$x$$$ and $$$y$$$ compete, the winner is decided as follows:  if $$$x+y$$$ is odd, the athlete with the lower index wins (i. e. if $$$x < y$$$, then $$$x$$$ wins, otherwise $$$y$$$ wins);  if $$$x+y$$$ is even, the athlete with the higher index wins. The following picture describes the way the tournament with $$$n = 3$$$ goes.  Your task is the following one: given the integer $$$n$$$, determine the index of the athlete who wins the tournament.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n \le 30$$$).

For each test case, print one integer — the index of the winner of the tournament.

NoteThe case $$$n = 3$$$ is shown in the picture from the statement.If $$$n = 1$$$, then there's only one match between athletes $$$1$$$ and $$$2$$$. Since $$$1 + 2 = 3$$$ is an odd number, the athlete with the lower index wins. So, the athlete $$$1$$$ is the winner.


Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. For example, numbers 47, 7744, 474477 are super lucky and 4, 744, 467 are not.One day Petya came across a positive integer n. Help him to find the least super lucky number which is not less than n.

The only line contains a positive integer n (1 ≤ n ≤ 10100000). This number doesn't have leading zeroes.

Output the least super lucky number that is more than or equal to n.


We've got no test cases. A big olympiad is coming up. But the problemsetters' number one priority should be adding another problem to the round. The diameter of a multiset of points on the line is the largest distance between two points from this set. For example, the diameter of the multiset {1, 3, 2, 1} is 2.Diameter of multiset consisting of one point is 0.You are given n points on the line. What is the minimum number of points you have to remove, so that the diameter of the multiset of the remaining points will not exceed d?

The first line contains two integers n and d (1 ≤ n ≤ 100, 0 ≤ d ≤ 100) — the amount of points and the maximum allowed diameter respectively. The second line contains n space separated integers (1 ≤ xi ≤ 100) — the coordinates of the points.

Output a single integer — the minimum number of points you have to remove.

NoteIn the first test case the optimal strategy is to remove the point with coordinate 4. The remaining points will have coordinates 1 and 2, so the diameter will be equal to 2 - 1 = 1.In the second test case the diameter is equal to 0, so its is unnecessary to remove any points. In the third test case the optimal strategy is to remove points with coordinates 1, 9 and 10. The remaining points will have coordinates 3, 4 and 6, so the diameter will be equal to 6 - 3 = 3.


Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.Right now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.Limak eats a lot and his weight is tripled after every year, while Bob's weight is doubled after every year.After how many full years will Limak become strictly larger (strictly heavier) than Bob?

The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10) — the weight of Limak and the weight of Bob respectively.

Print one integer, denoting the integer number of years after which Limak will become strictly larger than Bob.

NoteIn the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is greater than the second one. Limak became larger than Bob after two years so you should print 2.In the second sample, Limak's and Bob's weights in next years are: 12 and 18, then 36 and 36, and finally 108 and 72 (after three years). The answer is 3. Remember that Limak wants to be larger than Bob and he won't be satisfied with equal weights.In the third sample, Limak becomes larger than Bob after the first year. Their weights will be 3 and 2 then.


After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the area of the rectangle must be positive. Wilbur had all four vertices of the planned pool written on a paper, until his friend came along and erased some of the vertices.Now Wilbur is wondering, if the remaining n vertices of the initial rectangle give enough information to restore the area of the planned swimming pool.

The first line of the input contains a single integer n (1 ≤ n ≤ 4) — the number of vertices that were not erased by Wilbur's friend. Each of the following n lines contains two integers xi and yi ( - 1000 ≤ xi, yi ≤ 1000) —the coordinates of the i-th vertex that remains. Vertices are given in an arbitrary order. It's guaranteed that these points are distinct vertices of some rectangle, that has positive area and which sides are parallel to the coordinate axes.

Print the area of the initial rectangle if it could be uniquely determined by the points remaining. Otherwise, print  - 1.

NoteIn the first sample, two opposite corners of the initial rectangle are given, and that gives enough information to say that the rectangle is actually a unit square.In the second sample there is only one vertex left and this is definitely not enough to uniquely define the area.