Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.Limak has a string s that consists of uppercase English letters. In one move he can swap two adjacent letters of the string. For example, he can transform a string "ABBC" into "BABC" or "ABCB" in one move.Limak wants to obtain a string without a substring "VK" (i.e. there should be no letter 'V' immediately followed by letter 'K'). It can be easily proved that it's possible for any initial string s.What is the minimum possible number of moves Limak can do?

The first line of the input contains an integer n (1 ≤ n ≤ 75) — the length of the string. The second line contains a string s, consisting of uppercase English letters. The length of the string is equal to n.

Print one integer, denoting the minimum possible number of moves Limak can do, in order to obtain a string without a substring "VK".

NoteIn the first sample, the initial string is "VKVK". The minimum possible number of moves is 3. One optimal sequence of moves is: Swap two last letters. The string becomes "VKKV". Swap first two letters. The string becomes "KVKV". Swap the second and the third letter. The string becomes "KKVV". Indeed, this string doesn't have a substring "VK".In the second sample, there are two optimal sequences of moves. One is "BVVKV"  →  "VBVKV"  →  "VVBKV". The other is "BVVKV"  →  "BVKVV"  →  "BKVVV".In the fifth sample, no swaps are necessary.


Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom.King Copa has already done the first three things. Now he just needs to travel all over the kingdom. The kingdom is an infinite plane with Cartesian coordinate system on it. Every city is a point on this plane. There are n cities in the kingdom at points with coordinates (x1, 0), (x2, 0), ..., (xn, 0), and there is one city at point (xn + 1, yn + 1). King starts his journey in the city number k. Your task is to find such route for the king, which visits all cities (in any order) and has minimum possible length. It is allowed to visit a city twice. The king can end his journey in any city. Between any pair of cities there is a direct road with length equal to the distance between the corresponding points. No two cities may be located at the same point.

The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ n + 1) — amount of cities and index of the starting city. The second line contains n + 1 numbers xi. The third line contains yn + 1. All coordinates are integers and do not exceed 106 by absolute value. No two cities coincide.

Output the minimum possible length of the journey. Your answer must have relative or absolute error less than 10 - 6.


Madoka wants to enter to "Novosibirsk State University", but in the entrance exam she came across a very difficult task:Given an integer $$$n$$$, it is required to calculate $$$\sum{\operatorname{lcm}(c, \gcd(a, b))}$$$, for all triples of positive integers $$$(a, b, c)$$$, where $$$a + b + c = n$$$.In this problem $$$\gcd(x, y)$$$ denotes the greatest common divisor of $$$x$$$ and $$$y$$$, and $$$\operatorname{lcm}(x, y)$$$ denotes the least common multiple of $$$x$$$ and $$$y$$$.Solve this problem for Madoka and help her to enter to the best university!

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

Print exactly one interger — $$$\sum{\operatorname{lcm}(c, \gcd(a, b))}$$$. Since the answer can be very large, then output it modulo $$$10^9 + 7$$$.

NoteIn the first example, there is only one suitable triple $$$(1, 1, 1)$$$. So the answer is $$$\operatorname{lcm}(1, \gcd(1, 1)) = \operatorname{lcm}(1, 1) = 1$$$.In the second example, $$$\operatorname{lcm}(1, \gcd(3, 1)) + \operatorname{lcm}(1, \gcd(2, 2)) + \operatorname{lcm}(1, \gcd(1, 3)) + \operatorname{lcm}(2, \gcd(2, 1)) + \operatorname{lcm}(2, \gcd(1, 2)) + \operatorname{lcm}(3, \gcd(1, 1)) = \operatorname{lcm}(1, 1) + \operatorname{lcm}(1, 2) + \operatorname{lcm}(1, 1) + \operatorname{lcm}(2, 1) + \operatorname{lcm}(2, 1) + \operatorname{lcm}(3, 1) = 1 + 2 + 1 + 2 + 2 + 3 = 11$$$


InputThe first line of the input contains a single integer $$$N$$$ ($$$1 \le N \le 24$$$). The next $$$N$$$ lines contain $$$5$$$ space-separated integers each. The first three integers will be between 0 and 2, inclusive. The last two integers will be between 0 and 3, inclusive. The sum of the first three integers will be equal to the sum of the last two integers.OutputOutput the result – a string of lowercase English letters.ExamplesInput
1
1 0 0 1 0
Output
a
Input
10
2 0 0 1 1
1 1 1 2 1
2 1 0 1 2
1 1 0 1 1
2 1 0 2 1
1 1 1 2 1
1 2 1 3 1
2 0 0 1 1
1 1 0 1 1
1 1 2 2 2
Output
codeforcez


Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game.Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards except for Borya himself. Borya knows which cards he has but he knows nothing about the order they lie in. Note that Borya can have multiple identical cards (and for each of the 25 types of cards he knows exactly how many cards of this type he has).The aim of the other players is to achieve the state when Borya knows the color and number value of each of his cards. For that, other players can give him hints. The hints can be of two types: color hints and value hints. A color hint goes like that: a player names some color and points at all the cards of this color. Similarly goes the value hint. A player names some value and points at all the cards that contain the value.Determine what minimum number of hints the other players should make for Borya to be certain about each card's color and value.

The first line contains integer n (1 ≤ n ≤ 100) — the number of Borya's cards. The next line contains the descriptions of n cards. The description of each card consists of exactly two characters. The first character shows the color (overall this position can contain five distinct letters — R, G, B, Y, W). The second character shows the card's value (a digit from 1 to 5). Borya doesn't know exact order of the cards they lie in.

Print a single integer — the minimum number of hints that the other players should make.

NoteIn the first sample Borya already knows for each card that it is a green three.In the second sample we can show all fours and all red cards.In the third sample you need to make hints about any four colors.


A car moves from point A to point B at speed v meters per second. The action takes place on the X-axis. At the distance d meters from A there are traffic lights. Starting from time 0, for the first g seconds the green light is on, then for the following r seconds the red light is on, then again the green light is on for the g seconds, and so on.The car can be instantly accelerated from 0 to v and vice versa, can instantly slow down from the v to 0. Consider that it passes the traffic lights at the green light instantly. If the car approaches the traffic lights at the moment when the red light has just turned on, it doesn't have time to pass it. But if it approaches the traffic lights at the moment when the green light has just turned on, it can move. The car leaves point A at the time 0.What is the minimum time for the car to get from point A to point B without breaking the traffic rules?

The first line contains integers l, d, v, g, r (1 ≤ l, d, v, g, r ≤ 1000, d < l) — the distance between A and B (in meters), the distance from A to the traffic lights, car's speed, the duration of green light and the duration of red light.

Output a single number — the minimum time that the car needs to get from point A to point B. Your output must have relative or absolute error less than 10 - 6.


Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5.... The sequence is built in the following way: at first the number 1 is written out, then the numbers from 1 to 2, then the numbers from 1 to 3, then the numbers from 1 to 4 and so on. Note that the sequence contains numbers, not digits. For example number 10 first appears in the sequence in position 55 (the elements are numerated from one).Find the number on the n-th position of the sequence.

The only line contains integer n (1 ≤ n ≤ 1014) — the position of the number to find. Note that the given number is too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

Print the element in the n-th position of the sequence (the elements are numerated from one).


This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that they found p grams of salt.To make a toast, each friend needs nl milliliters of the drink, a slice of lime and np grams of salt. The friends want to make as many toasts as they can, provided they all drink the same amount. How many toasts can each friend make?

The first and only line contains positive integers n, k, l, c, d, p, nl, np, not exceeding 1000 and no less than 1. The numbers are separated by exactly one space.

Print a single integer — the number of toasts each friend can make.

NoteA comment to the first sample: Overall the friends have 4 * 5 = 20 milliliters of the drink, it is enough to make 20 / 3 = 6 toasts. The limes are enough for 10 * 8 = 80 toasts and the salt is enough for 100 / 1 = 100 toasts. However, there are 3 friends in the group, so the answer is min(6, 80, 100) / 3 = 2.


Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n. Pasha likes rectangles but hates squares, so he wonders, how many ways are there to split a stick into four parts so that it's possible to form a rectangle using these parts, but is impossible to form a square.Your task is to help Pasha and count the number of such ways. Two ways to cut the stick are considered distinct if there exists some integer x, such that the number of parts of length x in the first way differ from the number of parts of length x in the second way.

The first line of the input contains a positive integer n (1 ≤ n ≤ 2·109) — the length of Pasha's stick.

The output should contain a single integer — the number of ways to split Pasha's stick into four parts of positive integer length so that it's possible to make a rectangle by connecting the ends of these parts, but is impossible to form a square.

NoteThere is only one way to divide the stick in the first sample {1, 1, 2, 2}.Four ways to divide the stick in the second sample are {1, 1, 9, 9}, {2, 2, 8, 8}, {3, 3, 7, 7} and {4, 4, 6, 6}. Note that {5, 5, 5, 5} doesn't work.


What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until... Today Petya opened the cupboard and found a scary note there. His parents had left him with duties: he should water their favourite flower all year, each day, in the morning, in the afternoon and in the evening. "Wait a second!" — thought Petya. He know for a fact that if he fulfills the parents' task in the i-th (1 ≤ i ≤ 12) month of the year, then the flower will grow by ai centimeters, and if he doesn't water the flower in the i-th month, then the flower won't grow this month. Petya also knows that try as he might, his parents won't believe that he has been watering the flower if it grows strictly less than by k centimeters. Help Petya choose the minimum number of months when he will water the flower, given that the flower should grow no less than by k centimeters.

The first line contains exactly one integer k (0 ≤ k ≤ 100). The next line contains twelve space-separated integers: the i-th (1 ≤ i ≤ 12) number in the line represents ai (0 ≤ ai ≤ 100).

Print the only integer — the minimum number of months when Petya has to water the flower so that the flower grows no less than by k centimeters. If the flower can't grow by k centimeters in a year, print -1.

NoteLet's consider the first sample test. There it is enough to water the flower during the seventh and the ninth month. Then the flower grows by exactly five centimeters.In the second sample Petya's parents will believe him even if the flower doesn't grow at all (k = 0). So, it is possible for Petya not to water the flower at all.


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$$$.


Рассмотрим следующий код сортировки слиянием на языке Python: def sort(a):  n = len(a)  b = [0 for i in range(n)]  log = []  def mergeSort(l, r):    if r - l <= 1:      return    m = (l + r) >> 1    mergeSort(l, m)    mergeSort(m, r)    i, j, k = l, m, l    while i < m and j < r:      if a[i] < a[j]:        log.append('0')        b[k] = a[i]        i += 1      else:        log.append('1')        b[k] = a[j]        j += 1      k += 1    while i < m:      b[k] = a[i]      i += 1      k += 1    while j < r:      b[k] = a[j]      j += 1      k += 1    for p in range(l, r):      a[p] = b[p]  mergeSort(0, n)  return "".join(log)Как можно заметить, этот код использует логирование — важнейший инструмент разработки.Старший разработчик ВКонтакте Вася сгенерировал перестановку $$$a$$$ (массив из $$$n$$$ различных целых чисел от $$$1$$$ до $$$n$$$), дал её на вход функции sort и получил на выходе строку $$$s$$$. На следующий день строку $$$s$$$ Вася нашёл, а перестановка $$$a$$$ потерялась. Вася хочет восстановить любую перестановку $$$a$$$ такую, что вызов функции sort от неё даст ту же строку $$$s$$$. Помогите ему!

Ввод содержит непустую строку $$$s$$$, состоящую из символов 0 и 1.  В этой версии задачи для любого теста существует перестановка длины $$$16$$$, удовлетворяющая условию. Тем не менее, ваш ответ может иметь любую длину, в том числе отличную от $$$16$$$.

В первой строке выведите целое число $$$n$$$ — длину перестановки. Во второй строке выведите $$$n$$$ различных целых чисел $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$1 \le a_i \le n$$$) — элементы перестановки. Если существует несколько вариантов ответа, выведите любой из них.


The final match of the Berland Football Cup has been held recently. The referee has shown $$$n$$$ yellow cards throughout the match. At the beginning of the match there were $$$a_1$$$ players in the first team and $$$a_2$$$ players in the second team.The rules of sending players off the game are a bit different in Berland football. If a player from the first team receives $$$k_1$$$ yellow cards throughout the match, he can no longer participate in the match — he's sent off. And if a player from the second team receives $$$k_2$$$ yellow cards, he's sent off. After a player leaves the match, he can no longer receive any yellow cards. Each of $$$n$$$ yellow cards was shown to exactly one player. Even if all players from one team (or even from both teams) leave the match, the game still continues.The referee has lost his records on who has received each yellow card. Help him to determine the minimum and the maximum number of players that could have been thrown out of the game.

The first line contains one integer $$$a_1$$$ $$$(1 \le a_1 \le 1\,000)$$$ — the number of players in the first team. The second line contains one integer $$$a_2$$$ $$$(1 \le a_2 \le 1\,000)$$$ — the number of players in the second team. The third line contains one integer $$$k_1$$$ $$$(1 \le k_1 \le 1\,000)$$$ — the maximum number of yellow cards a player from the first team can receive (after receiving that many yellow cards, he leaves the game). The fourth line contains one integer $$$k_2$$$ $$$(1 \le k_2 \le 1\,000)$$$ — the maximum number of yellow cards a player from the second team can receive (after receiving that many yellow cards, he leaves the game). The fifth line contains one integer $$$n$$$ $$$(1 \le n \le a_1 \cdot k_1 + a_2 \cdot k_2)$$$ — the number of yellow cards that have been shown during the match.

Print two integers — the minimum and the maximum number of players that could have been thrown out of the game.

NoteIn the first example it could be possible that no player left the game, so the first number in the output is $$$0$$$. The maximum possible number of players that could have been forced to leave the game is $$$4$$$ — one player from the first team, and three players from the second.In the second example the maximum possible number of yellow cards has been shown $$$(3 \cdot 6 + 1 \cdot 7 = 25)$$$, so in any case all players were sent off.


Amr loves Geometry. One day he came up with a very interesting problem.Amr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y').In one step Amr can put a pin to the border of the circle in a certain point, then rotate the circle around that pin by any angle and finally remove the pin.Help Amr to achieve his goal in minimum number of steps.

Input consists of 5 space-separated integers r, x, y, x' y' (1 ≤ r ≤ 105,  - 105 ≤ x, y, x', y' ≤ 105), circle radius, coordinates of original center of the circle and coordinates of destination center of the circle respectively.

Output a single integer — minimum number of steps required to move the center of the circle to the destination point.

NoteIn the first sample test the optimal way is to put a pin at point (0, 2) and rotate the circle by 180 degrees counter-clockwise (or clockwise, no matter).


John Doe has a list of all Fibonacci numbers modulo 1013. This list is infinite, it starts with numbers 0 and 1. Each number in the list, apart from the first two, is a sum of previous two modulo 1013. That is, John's list is made from the Fibonacci numbers' list by replacing each number there by the remainder when divided by 1013. John got interested in number f (0 ≤ f < 1013) and now wants to find its first occurrence in the list given above. Help John and find the number of the first occurence of number f in the list or otherwise state that number f does not occur in the list. The numeration in John's list starts from zero. There, the 0-th position is the number 0, the 1-st position is the number 1, the 2-nd position is the number 1, the 3-rd position is the number 2, the 4-th position is the number 3 and so on. Thus, the beginning of the list looks like this: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...

The first line contains the single integer f (0 ≤ f < 1013) — the number, which position in the list we should find. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Print a single number — the number of the first occurrence of the given number in John's list. If this number doesn't occur in John's list, print -1.


Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to west. Also, traffic moves only from north to south or only from south to north in each vertical street. It is possible to enter a horizontal street from a vertical street, or vice versa, at their intersection.  The mayor has received some street direction patterns. Your task is to check whether it is possible to reach any junction from any other junction in the proposed street direction pattern.

The first line of input contains two integers n and m, (2 ≤ n, m ≤ 20), denoting the number of horizontal streets and the number of vertical streets. The second line contains a string of length n, made of characters '<' and '>', denoting direction of each horizontal street. If the i-th character is equal to '<', the street is directed from east to west otherwise, the street is directed from west to east. Streets are listed in order from north to south. The third line contains a string of length m, made of characters '^' and 'v', denoting direction of each vertical street. If the i-th character is equal to '^', the street is directed from south to north, otherwise the street is directed from north to south. Streets are listed in order from west to east.

If the given pattern meets the mayor's criteria, print a single line containing "YES", otherwise print a single line containing "NO".

NoteThe figure above shows street directions in the second sample test case.


Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:  To make a "red bouquet", it needs 3 red flowers.  To make a "green bouquet", it needs 3 green flowers.  To make a "blue bouquet", it needs 3 blue flowers.  To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower. Help Fox Ciel to find the maximal number of bouquets she can make.

The first line contains three integers r, g and b (0 ≤ r, g, b ≤ 109) — the number of red, green and blue flowers.

Print the maximal number of bouquets Fox Ciel can make.

NoteIn test case 1, we can make 1 red bouquet, 2 green bouquets and 3 blue bouquets.In test case 2, we can make 1 red, 1 green, 1 blue and 1 mixing bouquet.


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

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

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

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


A string a of length m is called antipalindromic iff m is even, and for each i (1 ≤ i ≤ m) ai ≠ am - i + 1.Ivan has a string s consisting of n lowercase Latin letters; n is even. He wants to form some string t that will be an antipalindromic permutation of s. Also Ivan has denoted the beauty of index i as bi, and the beauty of t as the sum of bi among all indices i such that si = ti.Help Ivan to determine maximum possible beauty of t he can get.

The first line contains one integer n (2 ≤ n ≤ 100, n is even) — the number of characters in s. The second line contains the string s itself. It consists of only lowercase Latin letters, and it is guaranteed that its letters can be reordered to form an antipalindromic string. The third line contains n integer numbers b1, b2, ..., bn (1 ≤ bi ≤ 100), where bi is the beauty of index i.

Print one number — the maximum possible beauty of t.


Igor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn't hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain "some real funny stuff about swine influenza". The antivirus had no objections and Igor K. run the flash application he had downloaded. Immediately his QIP Infinium said: "invalid login/password".Igor K. entered the ISQ from his additional account and looked at the info of his main one. His name and surname changed to "H1N1" and "Infected" correspondingly, and the "Additional Information" field contained a strange-looking binary code 80 characters in length, consisting of zeroes and ones. "I've been hacked" — thought Igor K. and run the Internet Exploiter browser to quickly type his favourite search engine's address.Soon he learned that it really was a virus that changed ISQ users' passwords. Fortunately, he soon found out that the binary code was actually the encrypted password where each group of 10 characters stood for one decimal digit. Accordingly, the original password consisted of 8 decimal digits.Help Igor K. restore his ISQ account by the encrypted password and encryption specification.

The input data contains 11 lines. The first line represents the binary code 80 characters in length. That is the code written in Igor K.'s ISQ account's info. Next 10 lines contain pairwise distinct binary codes 10 characters in length, corresponding to numbers 0, 1, ..., 9.

Print one line containing 8 characters — The password to Igor K.'s ISQ account. It is guaranteed that the solution exists.


In modern cryptography much is tied to the algorithmic complexity of solving several problems. One of such problems is a discrete logarithm problem. It is formulated as follows:  Let's fix a finite field and two it's elements $$$a$$$ and $$$b$$$. One need to fun such $$$x$$$ that $$$a^x = b$$$ or detect there is no such x. It is most likely that modern mankind cannot solve the problem of discrete logarithm for a sufficiently large field size. For example, for a field of residues modulo prime number, primes of 1024 or 2048 bits are considered to be safe. However, calculations with such large numbers can place a significant load on servers that perform cryptographic operations. For this reason, instead of a simple module residue field, more complex fields are often used. For such field no fast algorithms that use a field structure are known, smaller fields can be used and operations can be properly optimized. Developer Nikolai does not trust the generally accepted methods, so he wants to invent his own. Recently, he read about a very strange field — nimbers, and thinks it's a great fit for the purpose. The field of nimbers is defined on a set of integers from 0 to $$$2^{2^k} - 1$$$ for some positive integer $$$k$$$ . Bitwise exclusive or ($$$\oplus$$$) operation is used as addition. One of ways to define multiplication operation ($$$\odot$$$) is following properties:   $$$0 \odot a = a \odot 0 = 0$$$  $$$1 \odot a = a \odot 1 = a$$$  $$$a \odot b = b \odot a$$$  $$$a \odot (b \odot c)= (a \odot b) \odot c$$$  $$$a \odot (b \oplus c) = (a \odot b) \oplus (a \odot c)$$$  If $$$a = 2^{2^n}$$$ for some integer $$$n > 0$$$, and $$$b < a$$$, then $$$a \odot b = a \cdot b$$$.  If $$$a = 2^{2^n}$$$ for some integer $$$n > 0$$$, then $$$a \odot a = \frac{3}{2}\cdot a$$$. For example:   $$$ 4 \odot 4 = 6$$$  $$$ 8 \odot 8 = 4 \odot 2 \odot 4 \odot 2 = 4 \odot 4 \odot 2 \odot 2 = 6 \odot 3 = (4 \oplus 2) \odot 3 = (4 \odot 3) \oplus (2 \odot (2 \oplus 1)) = (4 \odot 3) \oplus (2 \odot 2) \oplus (2 \odot 1) = 12 \oplus 3 \oplus 2 = 13.$$$  $$$32 \odot 64 = (16 \odot 2) \odot (16 \odot 4) = (16 \odot 16) \odot (2 \odot 4) = 24 \odot 8 = (16 \oplus 8) \odot 8 = (16 \odot 8) \oplus (8 \odot 8) = 128 \oplus 13 = 141$$$  $$$5 \odot 6 = (4 \oplus 1) \odot (4 \oplus 2) = (4\odot 4) \oplus (4 \odot 2) \oplus (4 \odot 1) \oplus (1 \odot 2) = 6 \oplus 8 \oplus 4 \oplus 2 = 8$$$ Formally, this algorithm can be described by following pseudo-code. multiply(a, b) {   ans = 0   for p1 in bits(a)       // numbers of bits of a equal to one       for p2 in bits(b)   // numbers of bits of b equal to one          ans = ans xor multiply_powers_of_2(1 << p1, 1 << p2)   return ans;}multiply_powers_of_2(a, b) {    if (a == 1 or b == 1) return a * b    n = maximal value, such 2^{2^{n}} <= max(a, b)    power = 2^{2^{n}};    if (a >= power and b >= power) {        return multiply(power * 3 / 2, multiply_powers_of_2(a / power, b / power))    } else if (a >= power) {        return multiply_powers_of_2(a / power, b) * power    } else {        return multiply_powers_of_2(a, b / power) * power    }}It can be shown, that this operations really forms a field. Moreover, than can make sense as game theory operations, but that's not related to problem much. With the help of appropriate caching and grouping of operations, it is possible to calculate the product quickly enough, which is important to improve speed of the cryptoalgorithm. More formal definitions as well as additional properties can be clarified in the wikipedia article at link. The authors of the task hope that the properties listed in the statement should be enough for the solution. Powering for such muliplication is defined in same way, formally $$$a^{\odot k} = \underbrace{a \odot a \odot \cdots \odot a}_{k~\texttt{times}}$$$.You need to analyze the proposed scheme strength. For pairs of numbers $$$a$$$ and $$$b$$$ you need to find such $$$x$$$, that $$$a^{\odot x} = b$$$, or determine that it doesn't exist.

In the first line of input there is single integer $$$t$$$ ($$$1 \le t \le 100$$$) — number of pairs, for which you need to find the discrete logarithm. In each of next $$$t$$$ line there is a pair of integers $$$a$$$ $$$b$$$ ($$$1 \le a, b < 2^{64}$$$).

For each pair you should print one integer $$$x$$$ ($$$0 \le x < 2^{64}$$$), such that $$$a^{\odot x} = b$$$, or -1 if no such x exists. It can be shown, that if any such $$$x$$$ exists, there is one inside given bounds. If there are several good values, you can output any of them.


A flea is sitting at one of the n hassocks, arranged in a circle, at the moment. After minute number k the flea jumps through k - 1 hassoсks (clockwise). For example, after the first minute the flea jumps to the neighboring hassock. You should answer: will the flea visit all the hassocks or not. We assume that flea has infinitely much time for this jumping.

The only line contains single integer: 1 ≤ n ≤ 1000 — number of hassocks.

Output "YES" if all the hassocks will be visited and "NO" otherwise.


Your search for Heidi is over – you finally found her at a library, dressed up as a human. In fact, she has spent so much time there that she now runs the place! Her job is to buy books and keep them at the library so that people can borrow and read them. There are n different books, numbered 1 through n.We will look at the library's operation during n consecutive days. Heidi knows in advance that on the i-th day (1 ≤ i ≤ n) precisely one person will come to the library, request to borrow the book ai, read it in a few hours, and return the book later on the same day.Heidi desperately wants to please all her guests, so she will make sure to always have the book ai available in the library on the i-th day. During the night before the i-th day, she has the option of going to the bookstore (which operates at nights to avoid competition with the library) and buying any book for the price of 1 CHF. Of course, if she already has a book at the library, she does not need to buy it again. Initially, the library contains no books.There is a problem, though. The capacity of the library is k – this means that at any time, there can be at most k books at the library. If buying a new book would cause Heidi to have more than k books, she must first get rid of some book that she already has, in order to make room for the new book. If she later needs a book that she got rid of, she will need to buy that book again.You are given k and the sequence of requests for books a1, a2, ..., an. What is the minimum cost (in CHF) of buying new books to satisfy all the requests?

The first line of input will contain two integers n and k (1 ≤ n, k ≤ 80). The second line will contain n integers a1, a2, ..., an (1 ≤ ai ≤ n) – the sequence of book requests.

On a single line print the minimum cost of buying books at the store so as to satisfy all requests.

NoteIn the first test case, Heidi is able to keep all books forever. Therefore, she only needs to buy the book 1 before the first day and the book 2 before the second day.In the second test case, she can only keep one book at a time. Therefore she will need to buy new books on the first, second and fourth day.In the third test case, before buying book 3 on the third day, she must decide which of the books 1 and 2 she should get rid of. Of course, she should keep the book 1, which will be requested on the fourth day.


A sequence of integers $$$b_1, b_2, \ldots, b_m$$$ is called good if $$$max(b_1, b_2, \ldots, b_m) \cdot min(b_1, b_2, \ldots, b_m) \ge b_1 + b_2 + \ldots + b_m$$$.A sequence of integers $$$a_1, a_2, \ldots, a_n$$$ is called perfect if every non-empty subsequence of $$$a$$$ is good.YouKn0wWho has two integers $$$n$$$ and $$$M$$$, $$$M$$$ is prime. Help him find the number, modulo $$$M$$$, of perfect sequences $$$a_1, a_2, \ldots, a_n$$$ such that $$$1 \le a_i \le n + 1$$$ for each integer $$$i$$$ from $$$1$$$ to $$$n$$$.A sequence $$$d$$$ is a subsequence of a sequence $$$c$$$ if $$$d$$$ can be obtained from $$$c$$$ by deletion of several (possibly, zero or all) elements.

The first and only line of the input contains two space-separated integers $$$n$$$ and $$$M$$$ ($$$1 \le n \le 200$$$; $$$10^8 \le M \le 10^9$$$). It is guaranteed that $$$M$$$ is prime.

Print a single integer  — the number of perfect sequences modulo $$$M$$$.

NoteIn the first test case, the perfect sequences are $$$[2, 2]$$$, $$$[2, 3]$$$, $$$[3, 2]$$$ and $$$[3, 3]$$$.In the second test case, some of the perfect sequences are $$$[3, 4, 3, 5]$$$, $$$[4, 5, 4, 4]$$$, $$$[4, 5, 5, 5]$$$ etc. One example of a sequence which is not perfect is $$$[2, 3, 3, 4]$$$, because, for example, the subsequence $$$[2, 3, 4]$$$ is not an good as $$$2 \cdot 4 < 2 + 3 + 4$$$.


Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.The game is played on the following field.  Players are making moves by turns. At first move a player can put his chip in any cell of any small field. For following moves, there are some restrictions: if during last move the opposite player put his chip to cell with coordinates (xl, yl) in some small field, the next move should be done in one of the cells of the small field with coordinates (xl, yl). For example, if in the first move a player puts his chip to lower left cell of central field, then the second player on his next move should put his chip into some cell of lower left field (pay attention to the first test case). If there are no free cells in the required field, the player can put his chip to any empty cell on any field.You are given current state of the game and coordinates of cell in which the last move was done. You should find all cells in which the current player can put his chip.A hare works as a postman in the forest, he likes to foul bears. Sometimes he changes the game field a bit, so the current state of the game could be unreachable. However, after his changes the cell where the last move was done is not empty. You don't need to find if the state is unreachable or not, just output possible next moves according to the rules.

First 11 lines contains descriptions of table with 9 rows and 9 columns which are divided into 9 small fields by spaces and empty lines. Each small field is described by 9 characters without spaces and empty lines. character "x" (ASCII-code 120) means that the cell is occupied with chip of the first player, character "o" (ASCII-code 111) denotes a field occupied with chip of the second player, character "." (ASCII-code 46) describes empty cell. The line after the table contains two integers x and y (1 ≤ x, y ≤ 9). They describe coordinates of the cell in table where the last move was done. Rows in the table are numbered from up to down and columns are numbered from left to right. It's guaranteed that cell where the last move was done is filled with "x" or "o". Also, it's guaranteed that there is at least one empty cell. It's not guaranteed that current state of game is reachable.

Output the field in same format with characters "!" (ASCII-code 33) on positions where the current player can put his chip. All other cells should not be modified.

NoteIn the first test case the first player made a move to lower left cell of central field, so the second player can put a chip only to cells of lower left field.In the second test case the last move was done to upper left cell of lower central field, however all cells in upper left field are occupied, so the second player can put his chip to any empty cell.In the third test case the last move was done to central cell of central field, so current player can put his chip to any cell of central field, which is already occupied, so he can move anywhere. Pay attention that this state of the game is unreachable.


Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:     ans = solve(l, r) % a;    if (ans <= 0)      ans += a; This code will fail only on the test with . You are given number a, help Little X to find a proper test for hack.

The first line contains a single integer a (1 ≤ a ≤ 1018).

Print two integers: l, r (1 ≤ l ≤ r < 10200) — the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.


The Little Elephant is playing with the Cartesian coordinates' system. Most of all he likes playing with integer points. The Little Elephant defines an integer point as a pair of integers (x; y), such that 0 ≤ x ≤ w and 0 ≤ y ≤ h. Thus, the Little Elephant knows only (w + 1)·(h + 1) distinct integer points.The Little Elephant wants to paint a triangle with vertexes at integer points, the triangle's area must be a positive integer. For that, he needs to find the number of groups of three points that form such triangle. At that, the order of points in a group matters, that is, the group of three points (0;0), (0;2), (2;2) isn't equal to the group (0;2), (0;0), (2;2).Help the Little Elephant to find the number of groups of three integer points that form a nondegenerate triangle with integer area.

A single line contains two integers w and h (1 ≤ w, h ≤ 4000).

In a single output line print an integer — the remainder of dividing the answer to the problem by 1000000007 (109 + 7).


There are four stones on an infinite line in integer coordinates $$$a_1, a_2, a_3, a_4$$$. The goal is to have the stones in coordinates $$$b_1, b_2, b_3, b_4$$$. The order of the stones does not matter, that is, a stone from any position $$$a_i$$$ can end up in at any position $$$b_j$$$, provided there is a required number of stones in each position (that is, if a coordinate $$$x$$$ appears $$$k$$$ times among numbers $$$b_1, \ldots, b_4$$$, there should be exactly $$$k$$$ stones at $$$x$$$ in the end).We are allowed to move stones with the following operation: choose two stones at distinct positions $$$x$$$ and $$$y$$$ with at least one stone each, and move one stone from $$$x$$$ to $$$2y - x$$$. In other words, the operation moves a stone to a symmetric position relative to some other stone. At any moment it is allowed to have any number of stones at the same position.Find any sequence of operations that achieves the goal, or determine that it is impossible. The sequence does not have to be shortest, but it may contain at most $$$1000$$$ operations.

The first line contains four integers $$$a_1, \ldots, a_4$$$ ($$$-10^9 \leq a_i \leq 10^9$$$) — initial coordinates of the stones. There may be multiple stones sharing the same coordinate. The second line contains four integers $$$b_1, \ldots, b_4$$$ ($$$-10^9 \leq b_i \leq 10^9$$$) — target coordinates of the stones. There may be multiple targets sharing the same coordinate.

If there is no sequence of operations that achieves the goal, print a single integer $$$-1$$$. Otherwise, on the first line print a single integer $$$k$$$ ($$$0 \leq k \leq 1000$$$) — the number of operations in your sequence. On the next $$$k$$$ lines, describe the operations. The $$$i$$$-th of these lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$x_i \neq y_i$$$) — coordinates of the moved stone and the center of symmetry stone for the $$$i$$$-th operation. For each operation $$$i$$$, there should at least one stone in each of the coordinates $$$x_i$$$ and $$$y_i$$$, and the resulting coordinate $$$2y_i - x_i$$$ must not exceed $$$10^{18}$$$ by absolute value. If there are multiple suitable sequences, print any of them. It is guaranteed that if there is a suitable sequence of operations, then there is also a suitable sequence that satisfies all the additional requirement.


Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.Kyota Ootori has just learned about cyclic representation of a permutation. A cycle is a sequence of numbers such that each element of this sequence is being mapped into the next element of this sequence (and the last element of the cycle is being mapped into the first element of the cycle). The cyclic representation is a representation of p as a collection of cycles forming p. For example, permutation p = [4, 1, 6, 2, 5, 3] has a cyclic representation that looks like (142)(36)(5) because 1 is replaced by 4, 4 is replaced by 2, 2 is replaced by 1, 3 and 6 are swapped, and 5 remains in place. Permutation may have several cyclic representations, so Kyoya defines the standard cyclic representation of a permutation as follows. First, reorder the elements within each cycle so the largest element is first. Then, reorder all of the cycles so they are sorted by their first element. For our example above, the standard cyclic representation of [4, 1, 6, 2, 5, 3] is (421)(5)(63).Now, Kyoya notices that if we drop the parenthesis in the standard cyclic representation, we get another permutation! For instance, [4, 1, 6, 2, 5, 3] will become [4, 2, 1, 5, 6, 3].Kyoya notices that some permutations don't change after applying operation described above at all. He wrote all permutations of length n that do not change in a list in lexicographic order. Unfortunately, his friend Tamaki Suoh lost this list. Kyoya wishes to reproduce the list and he needs your help. Given the integers n and k, print the permutation that was k-th on Kyoya's list.

The first line will contain two integers n, k (1 ≤ n ≤ 50, 1 ≤ k ≤ min{1018, l} where l is the length of the Kyoya's list).

Print n space-separated integers, representing the permutation that is the answer for the question.

NoteThe standard cycle representation is (1)(32)(4), which after removing parenthesis gives us the original permutation. The first permutation on the list would be [1, 2, 3, 4], while the second permutation would be [1, 2, 4, 3].


Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was n integers a1, a2, ..., an. These numbers mean that Greg needs to do exactly n exercises today. Besides, Greg should repeat the i-th in order exercise ai times.Greg now only does three types of exercises: "chest" exercises, "biceps" exercises and "back" exercises. Besides, his training is cyclic, that is, the first exercise he does is a "chest" one, the second one is "biceps", the third one is "back", the fourth one is "chest", the fifth one is "biceps", and so on to the n-th exercise.Now Greg wonders, which muscle will get the most exercise during his training. We know that the exercise Greg repeats the maximum number of times, trains the corresponding muscle the most. Help Greg, determine which muscle will get the most training.

The first line contains integer n (1 ≤ n ≤ 20). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 25) — the number of times Greg repeats the exercises.

Print word "chest" (without the quotes), if the chest gets the most exercise, "biceps" (without the quotes), if the biceps gets the most exercise and print "back" (without the quotes) if the back gets the most exercise. It is guaranteed that the input is such that the answer to the problem is unambiguous.

NoteIn the first sample Greg does 2 chest, 8 biceps and zero back exercises, so the biceps gets the most exercises.In the second sample Greg does 5 chest, 1 biceps and 10 back exercises, so the back gets the most exercises.In the third sample Greg does 18 chest, 12 biceps and 8 back exercises, so the chest gets the most exercise.


An infinitely long Line Chillland Collider (LCC) was built in Chillland. There are $$$n$$$ pipes with coordinates $$$x_i$$$ that are connected to LCC. When the experiment starts at time 0, $$$i$$$-th proton flies from the $$$i$$$-th pipe with speed $$$v_i$$$. It flies to the right with probability $$$p_i$$$ and flies to the left with probability $$$(1 - p_i)$$$. The duration of the experiment is determined as the time of the first collision of any two protons. In case there is no collision, the duration of the experiment is considered to be zero.Find the expected value of the duration of the experiment.Illustration for the first example

The first line of input contains one integer $$$n$$$ — the number of pipes ($$$1 \le n \le 10^5$$$). Each of the following $$$n$$$ lines contains three integers $$$x_i$$$, $$$v_i$$$, $$$p_i$$$ — the coordinate of the $$$i$$$-th pipe, the speed of the $$$i$$$-th proton and the probability that the $$$i$$$-th proton flies to the right in percentage points ($$$-10^9 \le x_i \le 10^9, 1 \le v \le 10^6, 0 \le p_i \le 100$$$). It is guaranteed that all $$$x_i$$$ are distinct and sorted in increasing order.

It's possible to prove that the answer can always be represented as a fraction $$$P/Q$$$, where $$$P$$$ is an integer and $$$Q$$$ is a natural number not divisible by $$$998\,244\,353$$$. In this case, print $$$P \cdot Q^{-1}$$$ modulo $$$998\,244\,353$$$.


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.


Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio a:b. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio c:d. Manao adjusts the view in such a way that the movie preserves the original frame ratio, but also occupies as much space on the screen as possible and fits within it completely. Thus, he may have to zoom the movie in or out, but Manao will always change the frame proportionally in both dimensions.Calculate the ratio of empty screen (the part of the screen not occupied by the movie) to the total screen size. Print the answer as an irreducible fraction p / q.

A single line contains four space-separated integers a, b, c, d (1 ≤ a, b, c, d ≤ 1000).

Print the answer to the problem as "p/q", where p is a non-negative integer, q is a positive integer and numbers p and q don't have a common divisor larger than 1.

NoteSample 1. Manao's monitor has a square screen. The movie has 3:2 horizontal to vertical length ratio. Obviously, the movie occupies most of the screen if the width of the picture coincides with the width of the screen. In this case, only 2/3 of the monitor will project the movie in the horizontal dimension: Sample 2. This time the monitor's width is 4/3 times larger than its height and the movie's frame is square. In this case, the picture must take up the whole monitor in the vertical dimension and only 3/4 in the horizontal dimension:


Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every $$$a$$$ and $$$b$$$ such that $$$1 \leq a \leq b \leq 6$$$, there is exactly one domino with $$$a$$$ dots on one half and $$$b$$$ dots on the other half. The set contains exactly $$$21$$$ dominoes. Here is an exact illustration of his set:  Also, Anadi has an undirected graph without self-loops and multiple edges. He wants to choose some dominoes and place them on the edges of this graph. He can use at most one domino of each type. Each edge can fit at most one domino. It's not necessary to place a domino on each edge of the graph.When placing a domino on an edge, he also chooses its direction. In other words, one half of any placed domino must be directed toward one of the endpoints of the edge and the other half must be directed toward the other endpoint. There's a catch: if there are multiple halves of dominoes directed toward the same vertex, each of these halves must contain the same number of dots.How many dominoes at most can Anadi place on the edges of his graph?

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 7$$$, $$$0 \leq m \leq \frac{n\cdot(n-1)}{2}$$$) — the number of vertices and the number of edges in the graph. The next $$$m$$$ lines contain two integers each. Integers in the $$$i$$$-th line are $$$a_i$$$ and $$$b_i$$$ ($$$1 \leq a, b \leq n$$$, $$$a \neq b$$$) and denote that there is an edge which connects vertices $$$a_i$$$ and $$$b_i$$$. The graph might be disconnected. It's however guaranteed that the graph doesn't contain any self-loops, and that there is at most one edge between any pair of vertices.

Output one integer which denotes the maximum number of dominoes which Anadi can place on the edges of the graph.

NoteHere is an illustration of Anadi's graph from the first sample test:  And here is one of the ways to place a domino on each of its edges:  Note that each vertex is faced by the halves of dominoes with the same number of dots. For instance, all halves directed toward vertex $$$1$$$ have three dots.


The prestigious Codeforces kindergarten consists of n kids, numbered 1 through n. Each of them are given allowance in rubles by their parents.Today, they are going to the most famous candy shop in the town. The shop sells candies in packages: for all i between 1 and m, inclusive, it sells a package containing exactly i candies. A candy costs one ruble, so a package containing x candies costs x rubles.The kids will purchase candies in turns, starting from kid 1. In a single turn, kid i will purchase one candy package. Due to the highly competitive nature of Codeforces kindergarten, during a turn, the number of candies contained in the package purchased by the kid will always be strictly greater than the number of candies contained in the package purchased by the kid in the preceding turn (an exception is in the first turn: the first kid may purchase any package). Then, the turn proceeds to kid i + 1, or to kid 1 if it was kid n's turn. This process can be ended at any time, but at the end of the purchase process, all the kids must have the same number of candy packages. Of course, the amount spent by each kid on the candies cannot exceed their allowance.You work at the candy shop and would like to prepare the candies for the kids. Print the maximum number of candies that can be sold by the candy shop to the kids. If the kids cannot purchase any candy (due to insufficient allowance), print 0.

The first line contains two space-separated integers n and m (2 ≤ n ≤ 2·105, 2 ≤ m ≤ 5·106, n ≤ m), denoting the number of kids and the maximum number of candies in a package sold by the candy shop, respectively. Then n lines follow, each line will contain a single positive integer not exceeding  denoting the allowance of a kid in rubles. The allowances are given in order from kid 1 to kid n. Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is recommended to use cin, cout streams (also you may use %I64d specificator).

Print a single integer denoting the maximum number of candies that can be sold by the candy shop.

NoteFor the first example, one of the scenarios that will result in 13 purchased candies is as follows.   Turn 1. Kid 1 purchases 1 candy.  Turn 2. Kid 2 purchases 3 candies.  Turn 3. Kid 1 purchases 4 candies.  Turn 4. Kid 2 purchases 5 candies.


Arkady decided to buy roses for his girlfriend.A flower shop has white, orange and red roses, and the total amount of them is n. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red and white roses. Also, Arkady won't buy a bouquet where all roses have the same color. Arkady wants to buy exactly k roses. For each rose in the shop he knows its beauty and color: the beauty of the i-th rose is bi, and its color is ci ('W' for a white rose, 'O' for an orange rose and 'R' for a red rose). Compute the maximum possible total beauty of a bouquet of k roses satisfying the constraints above or determine that it is not possible to make such a bouquet.

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of roses in the show and the number of roses Arkady wants to buy. The second line contains a sequence of integers b1, b2, ..., bn (1 ≤ bi ≤ 10 000), where bi equals the beauty of the i-th rose. The third line contains a string c of length n, consisting of uppercase English letters 'W', 'O' and 'R', where ci denotes the color of the i-th rose: 'W' denotes white, 'O'  — orange, 'R' — red.

Print the maximum possible total beauty of a bouquet of k roses that satisfies the constraints above. If it is not possible to make a single such bouquet, print -1.

NoteIn the first example Arkady wants to buy 3 roses. He can, for example, buy both red roses (their indices are 1 and 2, and their total beauty is 7) and the only orange rose (its index is 3, its beauty is 4). This way the total beauty of the bouquet is 11. In the second example Arkady can not buy a bouquet because all roses have the same color.


Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.For every bullet that hits the shield, Ebony deals a units of damage while Ivory deals b units of damage. In order to break the shield Dante has to deal exactly c units of damage. Find out if this is possible.

The first line of the input contains three integers a, b, c (1 ≤ a, b ≤ 100, 1 ≤ c ≤ 10 000) — the number of units of damage dealt by Ebony gun and Ivory gun, and the total number of damage required to break the shield, respectively.

Print "Yes" (without quotes) if Dante can deal exactly c damage to the shield and "No" (without quotes) otherwise.

NoteIn the second sample, Dante can fire 1 bullet from Ebony and 2 from Ivory to deal exactly 1·3 + 2·2 = 7 damage. In the third sample, Dante can fire 1 bullet from ebony and no bullets from ivory to do 1·6 + 0·11 = 6 damage.


Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat.One day the director of the F company got hold of the records of a part of an online meeting of one successful team. The director watched the record and wanted to talk to the team leader. But how can he tell who the leader is? The director logically supposed that the leader is the person who is present at any conversation during a chat meeting. In other words, if at some moment of time at least one person is present on the meeting, then the leader is present on the meeting.You are the assistant director. Given the 'user logged on'/'user logged off' messages of the meeting in the chronological order, help the director determine who can be the leader. Note that the director has the record of only a continuous part of the meeting (probably, it's not the whole meeting).

The first line contains integers n and m (1 ≤ n, m ≤ 105) — the number of team participants and the number of messages. Each of the next m lines contains a message in the format:   '+ id': the record means that the person with number id (1 ≤ id ≤ n) has logged on to the meeting.  '- id': the record means that the person with number id (1 ≤ id ≤ n) has logged off from the meeting.  Assume that all the people of the team are numbered from 1 to n and the messages are given in the chronological order. It is guaranteed that the given sequence is the correct record of a continuous part of the meeting. It is guaranteed that no two log on/log off events occurred simultaneously.

In the first line print integer k (0 ≤ k ≤ n) — how many people can be leaders. In the next line, print k integers in the increasing order — the numbers of the people who can be leaders. If the data is such that no member of the team can be a leader, print a single number 0.


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.


Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?The brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.

The only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 109).

Output one integer: the smallest number of brains in the chest which allows Heidi to merely survive.


You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.If a solution exists, you should print it.

The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.

Print "NO" (without quotes), if there is no such way to remove some digits from number n.  Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8. If there are multiple possible answers, you may print any of them.


Ildar took a band (a thin strip of cloth) and colored it. Formally, the band has $$$n$$$ cells, each of them is colored into one of $$$26$$$ colors, so we can denote each color with one of the lowercase letters of English alphabet. Ildar decided to take some segment of the band $$$[l, r]$$$ ($$$1 \le l \le r \le n$$$) he likes and cut it from the band. So he will create a new band that can be represented as a string $$$t = s_l s_{l+1} \ldots s_r$$$.After that Ildar will play the following game: he cuts the band $$$t$$$ into some new bands and counts the number of different bands among them. Formally, Ildar chooses $$$1 \le k \le |t|$$$ indexes $$$1 \le i_1 < i_2 < \ldots < i_k = |t|$$$ and cuts $$$t$$$ to $$$k$$$ bands-strings $$$t_1 t_2 \ldots t_{i_1}, t_{i_1 + 1} \ldots t_{i_2}, \ldots, {t_{i_{k-1} + 1}} \ldots t_{i_k}$$$ and counts the number of different bands among them. He wants to know the minimal possible number of different bands he can get under the constraint that at least one band repeats at least two times. The result of the game is this number. If it is impossible to cut $$$t$$$ in such a way, the result of the game is -1.Unfortunately Ildar hasn't yet decided which segment he likes, but he has $$$q$$$ segments-candidates $$$[l_1, r_1]$$$, $$$[l_2, r_2]$$$, ..., $$$[l_q, r_q]$$$. Your task is to calculate the result of the game for each of them.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) — the length of the band Ildar has. The second line contains a string $$$s$$$ consisting of $$$n$$$ lowercase English letters — the band Ildar has. The third line contains a single integer $$$q$$$ ($$$1 \le q \le 200\,000$$$) — the number of segments Ildar has chosen as candidates. Each of the next $$$q$$$ lines contains two integer integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le n$$$) denoting the ends of the $$$i$$$-th segment.

Output $$$q$$$ lines, where the $$$i$$$-th of them should contain the result of the game on the segment $$$[l_i, r_i]$$$.

NoteConsider the first example.If Ildar chooses the segment $$$[1, 6]$$$, he cuts a string $$$t = abcabc$$$. If he cuts $$$t$$$ into two bands $$$abc$$$ and $$$abc$$$, the band $$$abc$$$ repeats two times and the number of different tapes is $$$1$$$. So, the result of this game is $$$1$$$.If Ildar chooses the segment $$$[4, 7]$$$, he cuts a string $$$t = abcd$$$. It is impossible to cut this band in such a way that there is at least one band repeating at least two times. So, the result of this game is $$$-1$$$.If Ildar chooses the segment $$$[3, 6]$$$, he cuts a string $$$t = cabc$$$. If he cuts $$$t$$$ into three bands $$$c$$$, $$$ab$$$ and $$$c$$$, the band $$$c$$$ repeats two times and the number of different bands is $$$2$$$. So, the result of this game is $$$2$$$.


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

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

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

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


Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has?Please help Haruhi solve this problem.

The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters.

Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make.

NoteIn the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.


Little Petya loves training spiders. Petya has a board n × m in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. There are 5 possible commands: to stay idle or to move from current cell to some of the four side-neighboring cells (that is, one command for each of the four possible directions). Petya gives the commands so that no spider leaves the field. It is allowed for spiders to pass through each other when they crawl towards each other in opposite directions. All spiders crawl simultaneously and several spiders may end up in one cell. Petya wants to know the maximum possible number of spider-free cells after one second.

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 40, n·m ≤ 40) — the board sizes.

In the first line print the maximum number of cells without spiders.

NoteIn the first sample the only possible answer is:sIn the second sample one of the possible solutions is: rdlruls denotes command "stay idle", l, r, d, u denote commands "crawl left", "crawl right", "crawl down", "crawl up", correspondingly.


A mouse encountered a nice big cake and decided to take a walk across it, eating the berries on top of the cake on its way. The cake is rectangular, neatly divided into squares; some of the squares have a berry in them, and some don't.The mouse is in a bit of a hurry, though, so once she enters the cake from its northwest corner (the top left cell in the input data), she will only go east (right) or south (down), until she reaches the southeast corner (the bottom right cell). She will eat every berry in the squares she passes through, but not in the other squares.The mouse tries to choose her path so as to maximize the number of berries consumed. However, her haste and hunger might be clouding her judgement, leading her to suboptimal decisions...

The first line of input contains two integers $$$H$$$ and $$$W$$$ ($$$1 \le H, W \le 5$$$), separated by a space, — the height and the width of the cake. The next $$$H$$$ lines contain a string of $$$W$$$ characters each, representing the squares of the cake in that row: '.' represents an empty square, and '*' represents a square with a berry.

Output the number of berries the mouse will eat following her strategy.


Furik and Rubik love playing computer games. Furik has recently found a new game that greatly interested Rubik. The game consists of n parts and to complete each part a player may probably need to complete some other ones. We know that the game can be fully completed, that is, its parts do not form cyclic dependencies. Rubik has 3 computers, on which he can play this game. All computers are located in different houses. Besides, it has turned out that each part of the game can be completed only on one of these computers. Let's number the computers with integers from 1 to 3. Rubik can perform the following actions:   Complete some part of the game on some computer. Rubik spends exactly 1 hour on completing any part on any computer.  Move from the 1-st computer to the 2-nd one. Rubik spends exactly 1 hour on that.  Move from the 1-st computer to the 3-rd one. Rubik spends exactly 2 hours on that.  Move from the 2-nd computer to the 1-st one. Rubik spends exactly 2 hours on that.  Move from the 2-nd computer to the 3-rd one. Rubik spends exactly 1 hour on that.  Move from the 3-rd computer to the 1-st one. Rubik spends exactly 1 hour on that.  Move from the 3-rd computer to the 2-nd one. Rubik spends exactly 2 hours on that. Help Rubik to find the minimum number of hours he will need to complete all parts of the game. Initially Rubik can be located at the computer he considers necessary.

The first line contains integer n (1 ≤ n ≤ 200) — the number of game parts. The next line contains n integers, the i-th integer — ci (1 ≤ ci ≤ 3) represents the number of the computer, on which you can complete the game part number i.  Next n lines contain descriptions of game parts. The i-th line first contains integer ki (0 ≤ ki ≤ n - 1), then ki distinct integers ai, j (1 ≤ ai, j ≤ n; ai, j ≠ i) — the numbers of parts to complete before part i. Numbers on all lines are separated by single spaces. You can assume that the parts of the game are numbered from 1 to n in some way. It is guaranteed that there are no cyclic dependencies between the parts of the game.

On a single line print the answer to the problem.

NoteNote to the second sample: before the beginning of the game the best strategy is to stand by the third computer. First we complete part 5. Then we go to the 1-st computer and complete parts 3 and 4. Then we go to the 2-nd computer and complete parts 1 and 2. In total we get 1+1+2+1+2, which equals 7 hours.


Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from those sticks. They can make an animal from sticks in the following way:   Four sticks represent the animal's legs, these sticks should have the same length.  Two remaining sticks represent the animal's head and body. The bear's head stick must be shorter than the body stick. The elephant, however, has a long trunk, so his head stick must be as long as the body stick. Note that there are no limits on the relations between the leg sticks and the head and body sticks. Your task is to find out which animal can be made from the given stick set. The zoo keeper wants the sticks back after the game, so they must never be broken, even bears understand it.

The single line contains six space-separated integers li (1 ≤ li ≤ 9) — the lengths of the six sticks. It is guaranteed that the input is such that you cannot make both animals from the sticks.

If you can make a bear from the given set, print string "Bear" (without the quotes). If you can make an elephant, print string "Elephant" (wıthout the quotes). If you can make neither a bear nor an elephant, print string "Alien" (without the quotes).

NoteIf you're out of creative ideas, see instructions below which show how to make a bear and an elephant in the first two samples. The stick of length 2 is in red, the sticks of length 4 are in green, the sticks of length 5 are in blue.


When the curtains are opened, a canvas unfolds outside. Kanno marvels at all the blonde colours along the riverside — not tangerines, but blossoms instead."What a pity it's already late spring," sighs Mino with regret, "one more drizzling night and they'd be gone.""But these blends are at their best, aren't they?" Absorbed in the landscape, Kanno remains optimistic. The landscape can be expressed as a row of consecutive cells, each of which either contains a flower of colour amber or buff or canary yellow, or is empty.When a flower withers, it disappears from the cell that it originally belonged to, and it spreads petals of its colour in its two neighbouring cells (or outside the field if the cell is on the side of the landscape). In case petals fall outside the given cells, they simply become invisible.You are to help Kanno determine whether it's possible that after some (possibly none or all) flowers shed their petals, at least one of the cells contains all three colours, considering both petals and flowers. Note that flowers can wither in arbitrary order.

The first and only line of input contains a non-empty string $$$s$$$ consisting of uppercase English letters 'A', 'B', 'C' and characters '.' (dots) only ($$$\lvert s \rvert \leq 100$$$) — denoting cells containing an amber flower, a buff one, a canary yellow one, and no flowers, respectively.

Output "Yes" if it's possible that all three colours appear in some cell, and "No" otherwise. You can print each letter in any case (upper or lower).

NoteIn the first example, the buff and canary yellow flowers can leave their petals in the central cell, blending all three colours in it.In the second example, it's impossible to satisfy the requirement because there is no way that amber and buff meet in any cell.


For a sequence a of n integers between 1 and m, inclusive, denote f(a) as the number of distinct subsequences of a (including the empty subsequence).You are given two positive integers n and m. Let S be the set of all sequences of length n consisting of numbers from 1 to m. Compute the sum f(a) over all a in S modulo 109 + 7.

The only line contains two integers n and m (1 ≤ n, m ≤ 106) — the number of elements in arrays and the upper bound for elements.

Print the only integer c — the desired sum modulo 109 + 7.


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

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

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

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


Right now she actually isn't. But she will be, if you don't solve this problem.You are given integers n, k, A and B. There is a number x, which is initially equal to n. You are allowed to perform two types of operations:   Subtract 1 from x. This operation costs you A coins.  Divide x by k. Can be performed only if x is divisible by k. This operation costs you B coins.  What is the minimum amount of coins you have to pay to make x equal to 1?

The first line contains a single integer n (1 ≤ n ≤ 2·109). The second line contains a single integer k (1 ≤ k ≤ 2·109). The third line contains a single integer A (1 ≤ A ≤ 2·109). The fourth line contains a single integer B (1 ≤ B ≤ 2·109).

Output a single integer — the minimum amount of coins you have to pay to make x equal to 1.

NoteIn the first testcase, the optimal strategy is as follows:   Subtract 1 from x (9 → 8) paying 3 coins.  Divide x by 2 (8 → 4) paying 1 coin.  Divide x by 2 (4 → 2) paying 1 coin.  Divide x by 2 (2 → 1) paying 1 coin. The total cost is 6 coins.In the second test case the optimal strategy is to subtract 1 from x 4 times paying 8 coins in total.


Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.More formally, you are given an array s1, s2, ..., sn of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.Besides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.

The first line contains one integer number n (1 ≤ n ≤ 100). The second line contains n space-separated integer numbers s1, s2, ..., sn (0 ≤ si ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.

Print one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.


Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.The path consists of $$$n$$$ consecutive tiles, numbered from $$$1$$$ to $$$n$$$. Ujan will paint each tile in some color. He will consider the path aesthetic if for any two different tiles with numbers $$$i$$$ and $$$j$$$, such that $$$|j - i|$$$ is a divisor of $$$n$$$ greater than $$$1$$$, they have the same color. Formally, the colors of two tiles with numbers $$$i$$$ and $$$j$$$ should be the same if $$$|i-j| > 1$$$ and $$$n \bmod |i-j| = 0$$$ (where $$$x \bmod y$$$ is the remainder when dividing $$$x$$$ by $$$y$$$).Ujan wants to brighten up space. What is the maximum number of different colors that Ujan can use, so that the path is aesthetic?

The first line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^{12}$$$), the length of the path.

Output a single integer, the maximum possible number of colors that the path can be painted in.

NoteIn the first sample, two colors is the maximum number. Tiles $$$1$$$ and $$$3$$$ should have the same color since $$$4 \bmod |3-1| = 0$$$. Also, tiles $$$2$$$ and $$$4$$$ should have the same color since $$$4 \bmod |4-2| = 0$$$.In the second sample, all five colors can be used.


You've got a 5 × 5 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to right. In one move, you are allowed to apply one of the two following transformations to the matrix:  Swap two neighboring matrix rows, that is, rows with indexes i and i + 1 for some integer i (1 ≤ i < 5).  Swap two neighboring matrix columns, that is, columns with indexes j and j + 1 for some integer j (1 ≤ j < 5). You think that a matrix looks beautiful, if the single number one of the matrix is located in its middle (in the cell that is on the intersection of the third row and the third column). Count the minimum number of moves needed to make the matrix beautiful.

The input consists of five lines, each line contains five integers: the j-th integer in the i-th line of the input represents the element of the matrix that is located on the intersection of the i-th row and the j-th column. It is guaranteed that the matrix consists of 24 zeroes and a single number one.

Print a single integer — the minimum number of moves needed to make the matrix beautiful.


Seryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of size $$$n \times m$$$ cells on a map (rows of grid are numbered from $$$1$$$ to $$$n$$$ from north to south, and columns are numbered from $$$1$$$ to $$$m$$$ from west to east). After that he measured the average height of each cell above Rybinsk sea level and obtained a matrix of heights of size $$$n \times m$$$. The cell $$$(i, j)$$$ lies on the intersection of the $$$i$$$-th row and the $$$j$$$-th column and has height $$$h_{i, j}$$$. Seryozha is going to look at the result of his work in the browser. The screen of Seryozha's laptop can fit a subrectangle of size $$$a \times b$$$ of matrix of heights ($$$1 \le a \le n$$$, $$$1 \le b \le m$$$). Seryozha tries to decide how the weather can affect the recreation center — for example, if it rains, where all the rainwater will gather. To do so, he is going to find the cell having minimum height among all cells that are shown on the screen of his laptop.Help Seryozha to calculate the sum of heights of such cells for all possible subrectangles he can see on his screen. In other words, you have to calculate the sum of minimum heights in submatrices of size $$$a \times b$$$ with top left corners in $$$(i, j)$$$ over all $$$1 \le i \le n - a + 1$$$ and $$$1 \le j \le m - b + 1$$$.Consider the sequence $$$g_i = (g_{i - 1} \cdot x + y) \bmod z$$$. You are given integers $$$g_0$$$, $$$x$$$, $$$y$$$ and $$$z$$$. By miraculous coincidence, $$$h_{i, j} = g_{(i - 1) \cdot m + j - 1}$$$ ($$$(i - 1) \cdot m + j - 1$$$ is the index).

The first line of the input contains four integers $$$n$$$, $$$m$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n, m \le 3\,000$$$, $$$1 \le a \le n$$$, $$$1 \le b \le m$$$) — the number of rows and columns in the matrix Seryozha has, and the number of rows and columns that can be shown on the screen of the laptop, respectively. The second line of the input contains four integers $$$g_0$$$, $$$x$$$, $$$y$$$ and $$$z$$$ ($$$0 \le g_0, x, y < z \le 10^9$$$).

Print a single integer — the answer to the problem.


Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.Let's consider the following algorithm of generating a sequence of integers. Initially we have a sequence consisting of a single element equal to 1. Then we perform (n - 1) steps. On each step we take the sequence we've got on the previous step, append it to the end of itself and insert in the middle the minimum positive integer we haven't used before. For example, we get the sequence [1, 2, 1] after the first step, the sequence [1, 2, 1, 3, 1, 2, 1] after the second step.The task is to find the value of the element with index k (the elements are numbered from 1) in the obtained sequence, i. e. after (n - 1) steps.Please help Chloe to solve the problem!

The only line contains two integers n and k (1 ≤ n ≤ 50, 1 ≤ k ≤ 2n - 1).

Print single integer — the integer at the k-th position in the obtained sequence.

NoteIn the first sample the obtained sequence is [1, 2, 1, 3, 1, 2, 1]. The number on the second position is 2.In the second sample the obtained sequence is [1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1]. The number on the eighth position is 4.


Gerald has a friend, Pollard. Pollard is interested in lucky tickets (ticket is a sequence of digits). At first he thought that a ticket is lucky if between some its digits we can add arithmetic signs and brackets so that the result obtained by the arithmetic expression was number 100. But he quickly analyzed all such tickets and moved on to a more general question. Now he explores k-lucky tickets.Pollard sais that a ticket is k-lucky if we can add arithmetic operation signs between its digits to the left or right of them (i.e., "+", "-", " × ") and brackets so as to obtain the correct arithmetic expression whose value would equal k. For example, ticket "224201016" is 1000-lucky as ( - 2 - (2 + 4)) × (2 + 0) + 1016 = 1000.Pollard was so carried away by the lucky tickets that he signed up for a seminar on lucky tickets and, as far as Gerald knows, Pollard will attend it daily at 7 pm in some famous institute and will commute to it in the same tram for m days. In this tram tickets have eight digits. And Gerald wants to make a surprise for Pollard: each day Pollard will receive a tram k-lucky ticket. The conductor has already agreed to give Pollard certain tickets during all these m days and he only wants Gerald to tell him what kind of tickets to give out. In this regard, help Gerald pick exactly m distinct k-lucky tickets.

The single line contains two integers k and m (0 ≤ k ≤ 104, 1 ≤ m ≤ 3·105).

Print m lines. Each line must contain exactly 8 digits — the k-winning ticket. The tickets may begin with 0, all tickets must be distinct. If there are more than m distinct k-lucky tickets, print any m of them. It is guaranteed that at least m distinct k-lucky tickets exist. The tickets can be printed in any order.


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.


After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks.An intersection point is any point on the grid which is formed by the intersection of one horizontal stick and one vertical stick.In the grid shown below, n = 3 and m = 3. There are n + m = 6 sticks in total (horizontal sticks are shown in red and vertical sticks are shown in green). There are n·m = 9 intersection points, numbered from 1 to 9.  The rules of the game are very simple. The players move in turns. Akshat won gold, so he makes the first move. During his/her move, a player must choose any remaining intersection point and remove from the grid all sticks which pass through this point. A player will lose the game if he/she cannot make a move (i.e. there are no intersection points remaining on the grid at his/her move).Assume that both players play optimally. Who will win the game?

The first line of input contains two space-separated integers, n and m (1 ≤ n, m ≤ 100).

Print a single line containing "Akshat" or "Malvika" (without the quotes), depending on the winner of the game.

NoteExplanation of the first sample:The grid has four intersection points, numbered from 1 to 4.  If Akshat chooses intersection point 1, then he will remove two sticks (1 - 2 and 1 - 3). The resulting grid will look like this.  Now there is only one remaining intersection point (i.e. 4). Malvika must choose it and remove both remaining sticks. After her move the grid will be empty.In the empty grid, Akshat cannot make any move, hence he will lose.Since all 4 intersection points of the grid are equivalent, Akshat will lose no matter which one he picks.


On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off per year on Mars.

The first line of the input contains a positive integer n (1 ≤ n ≤ 1 000 000) — the number of days in a year on Mars.

Print two integers — the minimum possible and the maximum possible number of days off per year on Mars.

NoteIn the first sample there are 14 days in a year on Mars, and therefore independently of the day a year starts with there will be exactly 4 days off .In the second sample there are only 2 days in a year on Mars, and they can both be either work days or days off.


Fedya loves problems involving data structures. Especially ones about different queries on subsegments. Fedya had a nice array $$$a_1, a_2, \ldots a_n$$$ and a beautiful data structure. This data structure, given $$$l$$$ and $$$r$$$, $$$1 \le l \le r \le n$$$, could find the greatest integer $$$d$$$, such that $$$d$$$ divides each of $$$a_l$$$, $$$a_{l+1}$$$, ..., $$$a_{r}$$$. Fedya really likes this data structure, so he applied it to every non-empty contiguous subarray of array $$$a$$$, put all answers into the array and sorted it. He called this array $$$b$$$. It's easy to see that array $$$b$$$ contains $$$n(n+1)/2$$$ elements.After that, Fedya implemented another cool data structure, that allowed him to find sum $$$b_l + b_{l+1} + \ldots + b_r$$$ for given $$$l$$$ and $$$r$$$, $$$1 \le l \le r \le n(n+1)/2$$$. Surely, Fedya applied this data structure to every contiguous subarray of array $$$b$$$, called the result $$$c$$$ and sorted it. Help Fedya find the lower median of array $$$c$$$.Recall that for a sorted array of length $$$k$$$ the lower median is an element at position $$$\lfloor \frac{k + 1}{2} \rfloor$$$, if elements of the array are enumerated starting from $$$1$$$. For example, the lower median of array $$$(1, 1, 2, 3, 6)$$$ is $$$2$$$, and the lower median of $$$(0, 17, 23, 96)$$$ is $$$17$$$.

First line contains a single integer $$$n$$$ — number of elements in array $$$a$$$ ($$$1 \le n \le 50\,000$$$).  Second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ — elements of the array ($$$1 \le a_i \le 100\,000$$$).

Print a single integer — the lower median of array $$$c$$$.

NoteIn the first sample array $$$b$$$ is equal to $$${3, 3, 6}$$$, then array $$$c$$$ is equal to $$${3, 3, 6, 6, 9, 12}$$$, so the lower median is $$$6$$$.In the second sample $$$b$$$ is $$${8, 8, 8}$$$, $$$c$$$ is $$${8, 8, 8, 16, 16, 24}$$$, so the lower median is $$$8$$$.


Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home is located in point (a, b). In each step, he can move in a unit distance in horizontal or vertical direction. In other words, from position (x, y) he can go to positions (x + 1, y), (x - 1, y), (x, y + 1) or (x, y - 1). Unfortunately, Drazil doesn't have sense of direction. So he randomly chooses the direction he will go to in each step. He may accidentally return back to his house during his travel. Drazil may even not notice that he has arrived to (a, b) and continue travelling. Luckily, Drazil arrived to the position (a, b) successfully. Drazil said to Varda: "It took me exactly s steps to travel from my house to yours". But Varda is confused about his words, she is not sure that it is possible to get from (0, 0) to (a, b) in exactly s steps. Can you find out if it is possible for Varda?

You are given three integers a, b, and s ( - 109 ≤ a, b ≤ 109, 1 ≤ s ≤ 2·109) in a single line.

If you think Drazil made a mistake and it is impossible to take exactly s steps and get from his home to Varda's home, print "No" (without quotes). Otherwise, print "Yes".

NoteIn fourth sample case one possible route is: .