Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area.

To prove his skills, Ivan decided to demonstrate his friends a concept of random picture. A picture is a field of $n$ rows and $m$ columns, where each cell is either black or white. Ivan calls the picture random if for every cell it has at most one adjacent cell of the same color. Two cells are considered adjacent if they share a side.

Ivan's brothers spent some time trying to explain that it's not how the randomness usually works. Trying to convince Ivan, they want to count the number of different random (according to Ivan) pictures. Two pictures are considered different if at least one cell on those two picture is colored differently. Since the number of such pictures may be quite large, print it modulo $10^9 + 7$.

-----Input-----

The only line contains two integers $n$ and $m$ ($1 \le n, m \le 100\,000$), the number of rows and the number of columns of the field.

-----Output-----

Print one integer, the number of random pictures modulo $10^9 + 7$.

-----Example-----
Input
2 3

Output
8

-----Note-----

The picture below shows all possible random pictures of size $2$ by $3$.  [Image]


Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property:

  consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a;  for each pair x, y must exist some position j (1 ≤ j < n), such that at least one of the two conditions are met, either a_{j} = x, a_{j} + 1 = y, or a_{j} = y, a_{j} + 1 = x.

Sereja wants to build a beautiful array a, consisting of n integers. But not everything is so easy, Sereja's friend Dima has m coupons, each contains two integers q_{i}, w_{i}. Coupon i costs w_{i} and allows you to use as many numbers q_{i} as you want when constructing the array a. Values q_{i} are distinct. Sereja has no coupons, so Dima and Sereja have made the following deal. Dima builds some beautiful array a of n elements. After that he takes w_{i} rubles from Sereja for each q_{i}, which occurs in the array a. Sereja believed his friend and agreed to the contract, and now he is wondering, what is the maximum amount of money he can pay.

Help Sereja, find the maximum amount of money he can pay to Dima.

-----Input-----

The first line contains two integers n and m (1 ≤ n ≤ 2·10^6, 1 ≤ m ≤ 10^5). Next m lines contain pairs of integers. The i-th line contains numbers q_{i}, w_{i} (1 ≤ q_{i}, w_{i} ≤ 10^5).

It is guaranteed that all q_{i} are distinct.

-----Output-----

In a single line print maximum amount of money (in rubles) Sereja can pay.

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.

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

Output
5

Input
100 3
1 2
2 1
3 1

Output
4

Input
1 2
1 1
2 100

Output
100

-----Note-----

In the first sample Sereja can pay 5 rubles, for example, if Dima constructs the following array: [1, 2, 1, 2, 2]. There are another optimal arrays for this test.

In the third sample Sereja can pay 100 rubles, if Dima constructs the following array: [2].


Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside.

The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an arithmetic progression. For example, the string aab is hidden in string aaabb because it occurs at indices $1$, $3$, and $5$, which form an arithmetic progression with a common difference of $2$. Bessie thinks that any hidden string that occurs the most times is the secret message. Two occurrences of a subsequence of $S$ are distinct if the sets of indices are different. Help her find the number of occurrences of the secret message!

For example, in the string aaabb, a is hidden $3$ times, b is hidden $2$ times, ab is hidden $6$ times, aa is hidden $3$ times, bb is hidden $1$ time, aab is hidden $2$ times, aaa is hidden $1$ time, abb is hidden $1$ time, aaab is hidden $1$ time, aabb is hidden $1$ time, and aaabb is hidden $1$ time. The number of occurrences of the secret message is $6$.

-----Input-----

The first line contains a string $s$ of lowercase Latin letters ($1 \le |s| \le 10^5$) — the text that Bessie intercepted.

-----Output-----

Output a single integer  — the number of occurrences of the secret message.

-----Examples-----
Input
aaabb

Output
6

Input
usaco

Output
1

Input
lol

Output
2

-----Note-----

In the first example, these are all the hidden strings and their indice sets:   a occurs at $(1)$, $(2)$, $(3)$  b occurs at $(4)$, $(5)$  ab occurs at $(1,4)$, $(1,5)$, $(2,4)$, $(2,5)$, $(3,4)$, $(3,5)$  aa occurs at $(1,2)$, $(1,3)$, $(2,3)$  bb occurs at $(4,5)$  aab occurs at $(1,3,5)$, $(2,3,4)$  aaa occurs at $(1,2,3)$  abb occurs at $(3,4,5)$  aaab occurs at $(1,2,3,4)$  aabb occurs at $(2,3,4,5)$  aaabb occurs at $(1,2,3,4,5)$  Note that all the sets of indices are arithmetic progressions.

In the second example, no hidden string occurs more than once.

In the third example, the hidden string is the letter l.


Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 mark, 3 marks, 9 marks, 27 marks and so on. There are no coins of other denominations. Of course, Gerald likes it when he gets money without the change. And all buyers respect him and try to give the desired sum without change, if possible. But this does not always happen.

One day an unlucky buyer came. He did not have the desired sum without change. Then he took out all his coins and tried to give Gerald a larger than necessary sum with as few coins as possible. What is the maximum number of coins he could get?

The formal explanation of the previous paragraph: we consider all the possible combinations of coins for which the buyer can not give Gerald the sum of n marks without change. For each such combination calculate the minimum number of coins that can bring the buyer at least n marks. Among all combinations choose the maximum of the minimum number of coins. This is the number we want.

-----Input-----

The single line contains a single integer n (1 ≤ n ≤ 10^17).

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.

-----Output-----

In a single line print an integer: the maximum number of coins the unlucky buyer could have paid with.

-----Examples-----
Input
1

Output
1

Input
4

Output
2

-----Note-----

In the first test case, if a buyer has exactly one coin of at least 3 marks, then, to give Gerald one mark, he will have to give this coin. In this sample, the customer can not have a coin of one mark, as in this case, he will be able to give the money to Gerald without any change.

In the second test case, if the buyer had exactly three coins of 3 marks, then, to give Gerald 4 marks, he will have to give two of these coins. The buyer cannot give three coins as he wants to minimize the number of coins that he gives.


Note that girls in Arpa’s land are really attractive.

Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the a_{i}-th chair, and his girlfriend, sitting on the b_{i}-th chair. The chairs were numbered 1 through 2n in clockwise direction. There was exactly one person sitting on each chair.

 [Image]

There were two types of food: Kooft and Zahre-mar. Now Mehrdad wonders, was there any way to serve food for the guests such that:   Each person had exactly one type of food,  No boy had the same type of food as his girlfriend,  Among any three guests sitting on consecutive chairs, there was two of them who had different type of food. Note that chairs 2n and 1 are considered consecutive.

Find the answer for the Mehrdad question. If it was possible, find some arrangement of food types that satisfies the conditions.

-----Input-----

The first line contains an integer n (1  ≤  n  ≤  10^5) — the number of pairs of guests.

The i-th of the next n lines contains a pair of integers a_{i} and b_{i} (1  ≤ a_{i}, b_{i} ≤  2n) — the number of chair on which the boy in the i-th pair was sitting and the number of chair on which his girlfriend was sitting. It's guaranteed that there was exactly one person sitting on each chair.

-----Output-----

If there is no solution, print -1.

Otherwise print n lines, the i-th of them should contain two integers which represent the type of food for the i-th pair. The first integer in the line is the type of food the boy had, and the second integer is the type of food the girl had. If someone had Kooft, print 1, otherwise print 2.

If there are multiple solutions, print any of them.

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

Output
1 2
2 1
1 2


Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.

You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all already placed slimes. Then, while the last two slimes in the row have the same value v, you combine them together to create a slime with value v + 1.

You would like to see what the final state of the row is after you've added all n slimes. Please print the values of the slimes in the row from left to right.

-----Input-----

The first line of the input will contain a single integer, n (1 ≤ n ≤ 100 000).

-----Output-----

Output a single line with k integers, where k is the number of slimes in the row after you've finished the procedure described in the problem statement. The i-th of these numbers should be the value of the i-th slime from the left.

-----Examples-----
Input
1

Output
1

Input
2

Output
2

Input
3

Output
2 1

Input
8

Output
4

-----Note-----

In the first sample, we only have a single slime with value 1. The final state of the board is just a single slime with value 1.

In the second sample, we perform the following steps:

Initially we place a single slime in a row by itself. Thus, row is initially 1.

Then, we will add another slime. The row is now 1 1. Since two rightmost slimes have the same values, we should replace these slimes with one with value 2. Thus, the final state of the board is 2.

In the third sample, after adding the first two slimes, our row is 2. After adding one more slime, the row becomes 2 1.

In the last sample, the steps look as follows:   1  2  2 1  3  3 1  3 2  3 2 1  4


Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.

He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, such as madam or racecar.

Your task is to help Kolya and determine the minimum number of palindromes of equal lengths to cut s into, if it is allowed to rearrange letters in s before cuttings.

-----Input-----

The first line contains an integer n (1 ≤ n ≤ 4·10^5) — the length of string s.

The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits.

-----Output-----

Print to the first line an integer k — minimum number of palindromes into which you can cut a given string.

Print to the second line k strings — the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length.

-----Examples-----
Input
6
aabaac

Output
2
aba aca
Input
8
0rTrT022

Output
1
02TrrT20
Input
2
aA

Output
2
a A


Polycarpus takes part in the "Field of Wonders" TV show. The participants of the show have to guess a hidden word as fast as possible. Initially all the letters of the word are hidden.

The game consists of several turns. At each turn the participant tells a letter and the TV show host responds if there is such letter in the word or not. If there is such letter then the host reveals all such letters. For example, if the hidden word is "abacaba" and the player tells the letter "a", the host will reveal letters at all positions, occupied by "a": 1, 3, 5 and 7 (positions are numbered from left to right starting from 1).

Polycarpus knows m words of exactly the same length as the hidden word. The hidden word is also known to him and appears as one of these m words.

At current moment a number of turns have already been made and some letters (possibly zero) of the hidden word are already revealed. Previously Polycarp has told exactly the letters which are currently revealed.

It is Polycarpus' turn. He wants to tell a letter in such a way, that the TV show host will assuredly reveal at least one more letter. Polycarpus cannot tell the letters, which are already revealed.

Your task is to help Polycarpus and find out the number of letters he can tell so that the show host will assuredly reveal at least one of the remaining letters.

-----Input-----

The first line contains one integer n (1 ≤ n ≤ 50) — the length of the hidden word.

The following line describes already revealed letters. It contains the string of length n, which consists of lowercase Latin letters and symbols "*". If there is a letter at some position, then this letter was already revealed. If the position contains symbol "*", then the letter at this position has not been revealed yet. It is guaranteed, that at least one letter is still closed.

The third line contains an integer m (1 ≤ m ≤ 1000) — the number of words of length n, which Polycarpus knows. The following m lines contain the words themselves — n-letter strings of lowercase Latin letters. All words are distinct.

It is guaranteed that the hidden word appears as one of the given m words. Before the current move Polycarp has told exactly the letters which are currently revealed.

-----Output-----

Output the single integer — the number of letters Polycarpus can tell so that the TV show host definitely reveals at least one more letter. It is possible that this number is zero.

-----Examples-----
Input
4
a**d
2
abcd
acbd

Output
2

Input
5
lo*er
2
lover
loser

Output
0

Input
3
a*a
2
aaa
aba

Output
1

-----Note-----

In the first example Polycarpus can tell letters "b" and "c", which assuredly will be revealed.

The second example contains no letters which can be told as it is not clear, which of the letters "v" or "s" is located at the third position of the hidden word.

In the third example Polycarpus exactly knows that the hidden word is "aba", because in case it was "aaa", then the second letter "a" would have already been revealed in one of previous turns.


Instructors of Some Informatics School make students go to bed.

The house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned rooms. The rooms are arranged in a row and numbered from 1 to n. Initially, in i-th room there are a_{i} students. All students are currently somewhere in the house, therefore a_1 + a_2 + ... + a_{n} = nb. Also 2 instructors live in this house.

The process of curfew enforcement is the following. One instructor starts near room 1 and moves toward room n, while the second instructor starts near room n and moves toward room 1. After processing current room, each instructor moves on to the next one. Both instructors enter rooms and move simultaneously, if n is odd, then only the first instructor processes the middle room. When all rooms are processed, the process ends.

When an instructor processes a room, she counts the number of students in the room, then turns off the light, and locks the room. Also, if the number of students inside the processed room is not equal to b, the instructor writes down the number of this room into her notebook (and turns off the light, and locks the room). Instructors are in a hurry (to prepare the study plan for the next day), so they don't care about who is in the room, but only about the number of students.

While instructors are inside the rooms, students can run between rooms that are not locked and not being processed. A student can run by at most d rooms, that is she can move to a room with number that differs my at most d. Also, after (or instead of) running each student can hide under a bed in a room she is in. In this case the instructor will not count her during the processing. In each room any number of students can hide simultaneously.

Formally, here is what's happening:  A curfew is announced, at this point in room i there are a_{i} students.  Each student can run to another room but not further than d rooms away from her initial room, or stay in place. After that each student can optionally hide under a bed.  Instructors enter room 1 and room n, they count students there and lock the room (after it no one can enter or leave this room).  Each student from rooms with numbers from 2 to n - 1 can run to another room but not further than d rooms away from her current room, or stay in place. Each student can optionally hide under a bed.  Instructors move from room 1 to room 2 and from room n to room n - 1.  This process continues until all rooms are processed.

Let x_1 denote the number of rooms in which the first instructor counted the number of non-hidden students different from b, and x_2 be the same number for the second instructor. Students know that the principal will only listen to one complaint, therefore they want to minimize the maximum of numbers x_{i}. Help them find this value if they use the optimal strategy.

-----Input-----

The first line contains three integers n, d and b (2 ≤ n ≤ 100 000, 1 ≤ d ≤ n - 1, 1 ≤ b ≤ 10 000), number of rooms in the house, running distance of a student, official number of students in a room.

The second line contains n integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9), i-th of which stands for the number of students in the i-th room before curfew announcement.

It is guaranteed that a_1 + a_2 + ... + a_{n} = nb.

-----Output-----

Output one integer, the minimal possible value of the maximum of x_{i}.

-----Examples-----
Input
5 1 1
1 0 0 0 4

Output
1

Input
6 1 2
3 8 0 1 0 0

Output
2

-----Note-----

In the first sample the first three rooms are processed by the first instructor, and the last two are processed by the second instructor. One of the optimal strategies is the following: firstly three students run from room 5 to room 4, on the next stage two of them run to room 3, and one of those two hides under a bed. This way, the first instructor writes down room 2, and the second writes down nothing.

In the second sample one of the optimal strategies is the following: firstly all students in room 1 hide, all students from room 2 run to room 3. On the next stage one student runs from room 3 to room 4, and 5 students hide. This way, the first instructor writes down rooms 1 and 2, the second instructor writes down rooms 5 and 6.


Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in this!

Let us remind you that a number is called prime if it is integer larger than one, and is not divisible by any positive integer other than itself and one.

Rikhail calls a number a palindromic if it is integer, positive, and its decimal representation without leading zeros is a palindrome, i.e. reads the same from left to right and right to left.

One problem with prime numbers is that there are too many of them. Let's introduce the following notation: π(n) — the number of primes no larger than n, rub(n) — the number of palindromic numbers no larger than n. Rikhail wants to prove that there are a lot more primes than palindromic ones.

He asked you to solve the following problem: for a given value of the coefficient A find the maximum n, such that π(n) ≤ A·rub(n).

-----Input-----

The input consists of two positive integers p, q, the numerator and denominator of the fraction that is the value of A ($A = \frac{p}{q}$, $p, q \leq 10^{4}, \frac{1}{42} \leq \frac{p}{q} \leq 42$).

-----Output-----

If such maximum number exists, then print it. Otherwise, print "Palindromic tree is better than splay tree" (without the quotes).

-----Examples-----
Input
1 1

Output
40

Input
1 42

Output
1

Input
6 4

Output
172


Æsir - CHAOS Æsir - V.

"Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.

The time right now...... 00:01:12......

It's time."

The emotion samples are now sufficient. After almost 3 years, it's time for Ivy to awake her bonded sister, Vanessa.

The system inside A.R.C.'s Library core can be considered as an undirected graph with infinite number of processing nodes, numbered with all positive integers ($1, 2, 3, \ldots$). The node with a number $x$ ($x > 1$), is directly connected with a node with number $\frac{x}{f(x)}$, with $f(x)$ being the lowest prime divisor of $x$.

Vanessa's mind is divided into $n$ fragments. Due to more than 500 years of coma, the fragments have been scattered: the $i$-th fragment is now located at the node with a number $k_i!$ (a factorial of $k_i$).

To maximize the chance of successful awakening, Ivy decides to place the samples in a node $P$, so that the total length of paths from each fragment to $P$ is smallest possible. If there are multiple fragments located at the same node, the path from that node to $P$ needs to be counted multiple times.

In the world of zeros and ones, such a requirement is very simple for Ivy. Not longer than a second later, she has already figured out such a node.

But for a mere human like you, is this still possible?

For simplicity, please answer the minimal sum of paths' lengths from every fragment to the emotion samples' assembly node $P$.

-----Input-----

The first line contains an integer $n$ ($1 \le n \le 10^6$) — number of fragments of Vanessa's mind.

The second line contains $n$ integers: $k_1, k_2, \ldots, k_n$ ($0 \le k_i \le 5000$), denoting the nodes where fragments of Vanessa's mind are located: the $i$-th fragment is at the node with a number $k_i!$.

-----Output-----

Print a single integer, denoting the minimal sum of path from every fragment to the node with the emotion samples (a.k.a. node $P$).

As a reminder, if there are multiple fragments at the same node, the distance from that node to $P$ needs to be counted multiple times as well.

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

Output
5

Input
4
3 1 4 4

Output
6

Input
4
3 1 4 1

Output
6

Input
5
3 1 4 1 5

Output
11

-----Note-----

Considering the first $24$ nodes of the system, the node network will look as follows (the nodes $1!$, $2!$, $3!$, $4!$ are drawn bold):

[Image]

For the first example, Ivy will place the emotion samples at the node $1$. From here:

  The distance from Vanessa's first fragment to the node $1$ is $1$.  The distance from Vanessa's second fragment to the node $1$ is $0$.  The distance from Vanessa's third fragment to the node $1$ is $4$.

The total length is $5$.

For the second example, the assembly node will be $6$. From here:

  The distance from Vanessa's first fragment to the node $6$ is $0$.  The distance from Vanessa's second fragment to the node $6$ is $2$.  The distance from Vanessa's third fragment to the node $6$ is $2$.  The distance from Vanessa's fourth fragment to the node $6$ is again $2$.

The total path length is $6$.


Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, managed to get hold of the problem before the contest. Because he wants to make sure Iahub will be the one qualified, he tells Iahub the following task.

You're given an (1-based) array a with n elements. Let's define function f(i, j) (1 ≤ i, j ≤ n) as (i - j)^2 + g(i, j)^2. Function g is calculated by the following pseudo-code:

int g(int i, int j) {

    int sum = 0;

    for (int k = min(i, j) + 1; k <= max(i, j); k = k + 1)

        sum = sum + a[k];

    return sum;

}

Find a value min_{i} ≠ j  f(i, j).

Probably by now Iahub already figured out the solution to this problem. Can you?

-----Input-----

The first line of input contains a single integer n (2 ≤ n ≤ 100000). Next line contains n integers a[1], a[2], ..., a[n] ( - 10^4 ≤ a[i] ≤ 10^4).

-----Output-----

Output a single integer — the value of min_{i} ≠ j  f(i, j).

-----Examples-----
Input
4
1 0 0 -1

Output
1

Input
2
1 -1

Output
2


You are given two arrays A and B, each of size n. The error, E, between these two arrays is defined $E = \sum_{i = 1}^{n}(a_{i} - b_{i})^{2}$. You have to perform exactly k_1 operations on array A and exactly k_2 operations on array B. In one operation, you have to choose one element of the array and increase or decrease it by 1.

Output the minimum possible value of error after k_1 operations on array A and k_2 operations on array B have been performed.

-----Input-----

The first line contains three space-separated integers n (1 ≤ n ≤ 10^3), k_1 and k_2 (0 ≤ k_1 + k_2 ≤ 10^3, k_1 and k_2 are non-negative) — size of arrays and number of operations to perform on A and B respectively.

Second line contains n space separated integers a_1, a_2, ..., a_{n} ( - 10^6 ≤ a_{i} ≤ 10^6) — array A.

Third line contains n space separated integers b_1, b_2, ..., b_{n} ( - 10^6 ≤ b_{i} ≤ 10^6)— array B.

-----Output-----

Output a single integer — the minimum possible value of $\sum_{i = 1}^{n}(a_{i} - b_{i})^{2}$ after doing exactly k_1 operations on array A and exactly k_2 operations on array B.

-----Examples-----
Input
2 0 0
1 2
2 3

Output
2
Input
2 1 0
1 2
2 2

Output
0
Input
2 5 7
3 4
14 4

Output
1

-----Note-----

In the first sample case, we cannot perform any operations on A or B. Therefore the minimum possible error E = (1 - 2)^2 + (2 - 3)^2 = 2.

In the second sample case, we are required to perform exactly one operation on A. In order to minimize error, we increment the first element of A by 1. Now, A = [2, 2]. The error is now E = (2 - 2)^2 + (2 - 2)^2 = 0. This is the minimum possible error obtainable.

In the third sample case, we can increase the first element of A to 8, using the all of the 5 moves available to us. Also, the first element of B can be reduced to 8 using the 6 of the 7 available moves. Now A = [8, 4] and B = [8, 4]. The error is now E = (8 - 8)^2 + (4 - 4)^2 = 0, but we are still left with 1 move for array B. Increasing the second element of B to 5 using the left move, we get B = [8, 5] and E = (8 - 8)^2 + (4 - 5)^2 = 1.


There is a string S of length N consisting of characters 0 and 1. You will perform the following operation for each i = 1, 2, ..., m:
 - Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left and extending through the r_i-th character.
Here, the sequence l_i is non-decreasing.
How many values are possible for S after the M operations, modulo 1000000007(= 10^9+7)?

-----Constraints-----
 - 2≦N≦3000
 - 1≦M≦3000
 - S consists of characters 0 and 1.
 - The length of S equals N.
 - 1≦l_i < r_i≦N
 - l_i ≦ l_{i+1}

-----Input-----
The input is given from Standard Input in the following format:
N M
S
l_1 r_1
:
l_M r_M

-----Output-----
Print the number of the possible values for S after the M operations, modulo 1000000007.

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

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

After the first operation, S can be one of the following three: 01001, 00101 and 00011.
After the second operation, S can be one of the following six: 01100, 01010, 01001, 00011, 00101 and 00110.


Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to $120^{\circ}$. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.

He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.

-----Input-----

The first and the single line of the input contains 6 space-separated integers a_1, a_2, a_3, a_4, a_5 and a_6 (1 ≤ a_{i} ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.

-----Output-----

Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.

-----Examples-----
Input
1 1 1 1 1 1

Output
6

Input
1 2 1 2 1 2

Output
13

-----Note-----

This is what Gerald's hexagon looks like in the first sample:

$\theta$

And that's what it looks like in the second sample:

$A$


Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a_1, a_2, ..., a_{n} are good.

Now she is interested in good sequences. A sequence x_1, x_2, ..., x_{k} is called good if it satisfies the following three conditions:  The sequence is strictly increasing, i.e. x_{i} < x_{i} + 1 for each i (1 ≤ i ≤ k - 1).  No two adjacent elements are coprime, i.e. gcd(x_{i}, x_{i} + 1) > 1 for each i (1 ≤ i ≤ k - 1) (where gcd(p, q) denotes the greatest common divisor of the integers p and q).  All elements of the sequence are good integers.

Find the length of the longest good sequence.

-----Input-----

The input consists of two lines. The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of good integers. The second line contains a single-space separated list of good integers a_1, a_2, ..., a_{n} in strictly increasing order (1 ≤ a_{i} ≤ 10^5; a_{i} < a_{i} + 1).

-----Output-----

Print a single integer — the length of the longest good sequence.

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

Output
4

Input
9
1 2 3 5 6 7 8 9 10

Output
4

-----Note-----

In the first example, the following sequences are examples of good sequences: [2; 4; 6; 9], [2; 4; 6], [3; 9], [6]. The length of the longest good sequence is 4.


You are an intergalactic surgeon and you have an alien patient. For the purposes of this problem, we can and we will model this patient's body using a $2 \times (2k + 1)$ rectangular grid. The alien has $4k + 1$ distinct organs, numbered $1$ to $4k + 1$.

In healthy such aliens, the organs are arranged in a particular way. For example, here is how the organs of a healthy such alien would be positioned, when viewed from the top, for $k = 4$: [Image]

Here, the E represents empty space.

In general, the first row contains organs $1$ to $2k + 1$ (in that order from left to right), and the second row contains organs $2k + 2$ to $4k + 1$ (in that order from left to right) and then empty space right after.

Your patient's organs are complete, and inside their body, but they somehow got shuffled around! Your job, as an intergalactic surgeon, is to put everything back in its correct position. All organs of the alien must be in its body during the entire procedure. This means that at any point during the procedure, there is exactly one cell (in the grid) that is empty. In addition, you can only move organs around by doing one of the following things:  You can switch the positions of the empty space E with any organ to its immediate left or to its immediate right (if they exist). In reality, you do this by sliding the organ in question to the empty space;  You can switch the positions of the empty space E with any organ to its immediate top or its immediate bottom (if they exist) only if the empty space is on the leftmost column, rightmost column or in the centermost column. Again, you do this by sliding the organ in question to the empty space.

Your job is to figure out a sequence of moves you must do during the surgical procedure in order to place back all $4k + 1$ internal organs of your patient in the correct cells. If it is impossible to do so, you must say so.

-----Input-----

The first line of input contains a single integer $t$ ($1 \le t \le 4$) denoting the number of test cases. The next lines contain descriptions of the test cases.

Each test case consists of three lines. The first line contains a single integer $k$ ($1 \le k \le 15$) which determines the size of the grid. Then two lines follow. Each of them contains $2k + 1$ space-separated integers or the letter E. They describe the first and second rows of organs, respectively. It is guaranteed that all $4k + 1$ organs are present and there is exactly one E.

-----Output-----

For each test case, first, print a single line containing either:  SURGERY COMPLETE if it is possible to place back all internal organs in the correct locations;  SURGERY FAILED if it is impossible.

If it is impossible, then this is the only line of output for the test case. However, if it is possible, output a few more lines describing the sequence of moves to place the organs in the correct locations.

The sequence of moves will be a (possibly empty) string of letters u, d, l or r, representing sliding the organ that's directly above, below, to the left or to the right of the empty space, respectively, into the empty space. Print the sequence of moves in the following line, as such a string.

For convenience, you may use shortcuts to reduce the size of your output. You may use uppercase letters as shortcuts for sequences of moves. For example, you could choose T to represent the string lddrr. These shortcuts may also include other shortcuts on their own! For example, you could choose E to represent TruT, etc.

You may use any number of uppercase letters (including none) as shortcuts. The only requirements are the following:  The total length of all strings in your output for a single case is at most $10^4$;  There must be no cycles involving the shortcuts that are reachable from the main sequence;  The resulting sequence of moves is finite, after expanding all shortcuts. Note that the final sequence of moves (after expanding) may be much longer than $10^4$; the only requirement is that it's finite.

As an example, if T = lddrr, E = TruT and R = rrr, then TurTlER expands to:  TurTlER  lddrrurTlER  lddrrurlddrrlER  lddrrurlddrrlTruTR  lddrrurlddrrllddrrruTR  lddrrurlddrrllddrrrulddrrR  lddrrurlddrrllddrrrulddrrrrr

To use shortcuts, print each one of them in a single line as the uppercase letter, then space, and then the string that this shortcut represents. They may be printed in any order. At the end of all of those, print a single line containing DONE.

Note: You still need to print DONE even if you don't plan on using shortcuts.

Your sequence does not need to be the shortest. Any valid sequence of moves (satisfying the requirements above) will be accepted.

-----Example-----
Input
2
3
1 2 3 5 6 E 7
8 9 10 4 11 12 13
11
34 45 6 22 16 43 38 44 5 4 41 14 7 29 28 19 9 18 42 8 17 33 1
E 15 40 36 31 24 10 2 21 11 32 23 30 27 35 25 13 12 39 37 26 20 3

Output
SURGERY COMPLETE
IR
R SrS
S rr
I lldll
DONE
SURGERY FAILED

-----Note-----

There are three shortcuts defined in the first sample output:  R = SrS  S = rr  I = lldll

The sequence of moves is IR and it expands to:  IR  lldllR  lldllSrS  lldllrrrS  lldllrrrrr


For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:

 $f(i, j) = \left\{\begin{array}{ll}{P [ i ]} & {\text{if} j = 1} \\{f(P [ i ], j - 1)} & {\text{otherwise}} \end{array} \right.$

Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.

For given N, A, B, find a permutation P of integers from 1 to N such that for 1 ≤ i ≤ N, g(i) equals either A or B.

-----Input-----

The only line contains three integers N, A, B (1 ≤ N ≤ 10^6, 1 ≤ A, B ≤ N).

-----Output-----

If no such permutation exists, output -1. Otherwise, output a permutation of integers from 1 to N.

-----Examples-----
Input
9 2 5

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

Output
1 2 3

-----Note-----

In the first example, g(1) = g(6) = g(7) = g(9) = 2 and g(2) = g(3) = g(4) = g(5) = g(8) = 5

In the second example, g(1) = g(2) = g(3) = 1


Enough is enough. Too many times it happened that Vasya forgot to dispose of garbage and his apartment stank afterwards. Now he wants to create a garbage disposal plan and stick to it.

For each of next $n$ days Vasya knows $a_i$ — number of units of garbage he will produce on the $i$-th day. Each unit of garbage must be disposed of either on the day it was produced or on the next day. Vasya disposes of garbage by putting it inside a bag and dropping the bag into a garbage container. Each bag can contain up to $k$ units of garbage. It is allowed to compose and drop multiple bags into a garbage container in a single day.

Being economical, Vasya wants to use as few bags as possible. You are to compute the minimum number of bags Vasya needs to dispose of all of his garbage for the given $n$ days. No garbage should be left after the $n$-th day.

-----Input-----

The first line of the input contains two integers $n$ and $k$ ($1 \le n \le 2\cdot10^5, 1 \le k \le 10^9$) — number of days to consider and bag's capacity. The second line contains $n$ space separated integers $a_i$ ($0 \le a_i \le 10^9$) — the number of units of garbage produced on the $i$-th day.

-----Output-----

Output a single integer — the minimum number of bags Vasya needs to dispose of all garbage. Each unit of garbage should be disposed on the day it was produced or on the next day. No garbage can be left after the $n$-th day. In a day it is allowed to compose and drop multiple bags.

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

Output
3

Input
5 1
1000000000 1000000000 1000000000 1000000000 1000000000

Output
5000000000

Input
3 2
1 0 1

Output
2

Input
4 4
2 8 4 1

Output
4


Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.

Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now wants to select several consequent (contiguous) pieces of alternating colors to create a zebra. Let's call the number of selected pieces the length of the zebra.

Before assembling the zebra Grisha can make the following operation $0$ or more times. He splits the sequence in some place into two parts, then reverses each of them and sticks them together again. For example, if Grisha has pieces in the order "bwbbw" (here 'b' denotes a black strip, and 'w' denotes a white strip), then he can split the sequence as bw|bbw (here the vertical bar represents the cut), reverse both parts and obtain "wbwbb".

Determine the maximum possible length of the zebra that Grisha can produce.

-----Input-----

The only line contains a string $s$ ($1 \le |s| \le 10^5$, where $|s|$ denotes the length of the string $s$) comprised of lowercase English letters 'b' and 'w' only, where 'w' denotes a white piece and 'b' denotes a black piece.

-----Output-----

Print a single integer — the maximum possible zebra length.

-----Examples-----
Input
bwwwbwwbw

Output
5

Input
bwwbwwb

Output
3

-----Note-----

In the first example one of the possible sequence of operations is bwwwbww|bw $\to$ w|wbwwwbwb $\to$ wbwbwwwbw, that gives the answer equal to $5$.

In the second example no operation can increase the answer.


You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if the target cell is not occupied by an obstacle. You can't move beyond the boundaries of the labyrinth.

Unfortunately, your keyboard is about to break, so you can move left no more than x times and move right no more than y times. There are no restrictions on the number of moves up and down since the keys used to move up and down are in perfect condition.

Now you would like to determine for each cell whether there exists a sequence of moves that will put you from the starting cell to this particular one. How many cells of the board have this property?

-----Input-----

The first line contains two integers n, m (1 ≤ n, m ≤ 2000) — the number of rows and the number columns in the labyrinth respectively.

The second line contains two integers r, c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — index of the row and index of the column that define the starting cell.

The third line contains two integers x, y (0 ≤ x, y ≤ 10^9) — the maximum allowed number of movements to the left and to the right respectively.

The next n lines describe the labyrinth. Each of them has length of m and consists only of symbols '.' and '*'. The j-th character of the i-th line corresponds to the cell of labyrinth at row i and column j. Symbol '.' denotes the free cell, while symbol '*' denotes the cell with an obstacle.

It is guaranteed, that the starting cell contains no obstacles.

-----Output-----

Print exactly one integer — the number of cells in the labyrinth, which are reachable from starting cell, including the starting cell itself.

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

Output
10

Input
4 4
2 2
0 1
....
..*.
....
....

Output
7

-----Note-----

Cells, reachable in the corresponding example, are marked with '+'.

First example:

+++..

+***.

+++**

*+++.

Second example:

.++.

.+*.

.++.

.++.


You have a set of $n$ weights. You know that their masses are $a_1$, $a_2$, ..., $a_n$ grams, but you don't know which of them has which mass. You can't distinguish the weights.

However, your friend does know the mass of each weight. You can ask your friend to give you exactly $k$ weights with the total mass $m$ (both parameters $k$ and $m$ are chosen by you), and your friend will point to any valid subset of weights, if it is possible.

You are allowed to make this query only once. Find the maximum possible number of weights you can reveal after this query.

-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 100$) — the number of weights.

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

-----Output-----

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

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

Output
2

Input
6
1 2 4 4 4 9

Output
2

-----Note-----

In the first example we can ask for a subset of two weights with total mass being equal to $4$, and the only option is to get $\{2, 2\}$.

Another way to obtain the same result is to ask for a subset of two weights with the total mass of $5$ and get $\{1, 4\}$. It is easy to see that the two remaining weights have mass of $2$ grams each.

In the second example we can ask for a subset of two weights with total mass being $8$, and the only answer is $\{4, 4\}$. We can prove it is not possible to learn masses for three weights in one query, but we won't put the proof here.


Suppose you are given a string $s$ of length $n$ consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.

To compress the string, you have to represent $s$ as a concatenation of several non-empty strings: $s = t_{1} t_{2} \ldots t_{k}$. The $i$-th of these strings should be encoded with one of the two ways:  if $|t_{i}| = 1$, meaning that the current string consists of a single character, you can encode it paying $a$ coins;  if $t_{i}$ is a substring of $t_{1} t_{2} \ldots t_{i - 1}$, then you can encode it paying $b$ coins.

A string $x$ is a substring of a string $y$ if $x$ can be obtained from $y$ by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

So your task is to calculate the minimum possible number of coins you need to spend in order to compress the given string $s$.

-----Input-----

The first line contains three positive integers, separated by spaces: $n$, $a$ and $b$ ($1 \leq n, a, b \leq 5000$) — the length of the string, the cost to compress a one-character string and the cost to compress a string that appeared before.

The second line contains a single string $s$, consisting of $n$ lowercase English letters.

-----Output-----

Output a single integer — the smallest possible number of coins you need to spend to compress $s$.

-----Examples-----
Input
3 3 1
aba

Output
7

Input
4 1 1
abcd

Output
4

Input
4 10 1
aaaa

Output
12

-----Note-----

In the first sample case, you can set $t_{1} =$ 'a', $t_{2} =$ 'b', $t_{3} =$ 'a' and pay $3 + 3 + 1 = 7$ coins, since $t_{3}$ is a substring of $t_{1}t_{2}$.

In the second sample, you just need to compress every character by itself.

In the third sample, you set $t_{1} = t_{2} =$ 'a', $t_{3} =$ 'aa' and pay $10 + 1 + 1 = 12$ coins, since $t_{2}$ is a substring of $t_{1}$ and $t_{3}$ is a substring of $t_{1} t_{2}$.


Snuke has decided to play with N cards and a deque (that is, a double-ended queue).
Each card shows an integer from 1 through N, and the deque is initially empty.
Snuke will insert the cards at the beginning or the end of the deque one at a time, in order from 1 to N.
Then, he will perform the following action N times: take out the card from the beginning or the end of the deque and eat it.
Afterwards, we will construct an integer sequence by arranging the integers written on the eaten cards, in the order they are eaten. Among the sequences that can be obtained in this way, find the number of the sequences such that the K-th element is 1. Print the answer modulo 10^{9} + 7.

-----Constraints-----
 - 1 ≦ K ≦ N ≦ 2{,}000

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

-----Output-----
Print the answer modulo 10^{9} + 7.

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

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

There is one sequence satisfying the condition: 1,2. One possible way to obtain this sequence is the following:
 - Insert both cards, 1 and 2, at the end of the deque.
 - Eat the card at the beginning of the deque twice.


Molly Hooper has n different kinds of chemicals arranged in a line. Each of the chemicals has an affection value, The i-th of them has affection value a_{i}.

Molly wants Sherlock to fall in love with her. She intends to do this by mixing a contiguous segment of chemicals together to make a love potion with total affection value as a non-negative integer power of k. Total affection value of a continuous segment of chemicals is the sum of affection values of each chemical in that segment.

Help her to do so in finding the total number of such segments.

-----Input-----

The first line of input contains two integers, n and k, the number of chemicals and the number, such that the total affection value is a non-negative power of this number k. (1 ≤ n ≤ 10^5, 1 ≤ |k| ≤ 10).

Next line contains n integers a_1, a_2, ..., a_{n} ( - 10^9 ≤ a_{i} ≤ 10^9) — affection values of chemicals.

-----Output-----

Output a single integer — the number of valid segments.

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

Output
8

Input
4 -3
3 -6 -3 12

Output
3

-----Note-----

Do keep in mind that k^0 = 1.

In the first sample, Molly can get following different affection values:  2: segments [1, 1], [2, 2], [3, 3], [4, 4];

 4: segments [1, 2], [2, 3], [3, 4];

 6: segments [1, 3], [2, 4];

 8: segments [1, 4].

Out of these, 2, 4 and 8 are powers of k = 2. Therefore, the answer is 8.

In the second sample, Molly can choose segments [1, 2], [3, 3], [3, 4].


In the evening Polycarp decided to analyze his today's travel expenses on public transport.

The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along the route from one stop to the other and back. There is at most one bus running between a pair of stops.

Polycarp made n trips on buses. About each trip the stop where he started the trip and the the stop where he finished are known. The trips follow in the chronological order in Polycarp's notes.

It is known that one trip on any bus costs a burles. In case when passenger makes a transshipment the cost of trip decreases to b burles (b < a). A passenger makes a transshipment if the stop on which he boards the bus coincides with the stop where he left the previous bus. Obviously, the first trip can not be made with transshipment.

For example, if Polycarp made three consecutive trips: "BerBank" $\rightarrow$ "University", "University" $\rightarrow$ "BerMall", "University" $\rightarrow$ "BerBank", then he payed a + b + a = 2a + b burles. From the BerBank he arrived to the University, where he made transshipment to the other bus and departed to the BerMall. Then he walked to the University and returned to the BerBank by bus.

Also Polycarp can buy no more than k travel cards. Each travel card costs f burles. The travel card for a single bus route makes free of charge any trip by this route (in both directions). Once purchased, a travel card can be used any number of times in any direction.

What is the smallest amount of money Polycarp could have spent today if he can buy no more than k travel cards?

-----Input-----

The first line contains five integers n, a, b, k, f (1 ≤ n ≤ 300, 1 ≤ b < a ≤ 100, 0 ≤ k ≤ 300, 1 ≤ f ≤ 1000) where:  n — the number of Polycarp trips,  a — the cost of a regualar single trip,  b — the cost of a trip after a transshipment,  k — the maximum number of travel cards Polycarp can buy,  f — the cost of a single travel card.

The following n lines describe the trips in the chronological order. Each line contains exactly two different words separated by a single space — the name of the start stop and the name of the finish stop of the trip. All names consist of uppercase and lowercase English letters and have lengths between 1 to 20 letters inclusive. Uppercase and lowercase letters should be considered different.

-----Output-----

Print the smallest amount of money Polycarp could have spent today, if he can purchase no more than k travel cards.

-----Examples-----
Input
3 5 3 1 8
BerBank University
University BerMall
University BerBank

Output
11

Input
4 2 1 300 1000
a A
A aa
aa AA
AA a

Output
5

-----Note-----

In the first example Polycarp can buy travel card for the route "BerBank $\leftrightarrow$ University" and spend 8 burles. Note that his second trip "University" $\rightarrow$ "BerMall" was made after transshipment, so for this trip Polycarp payed 3 burles. So the minimum total sum equals to 8 + 3 = 11 burles.

In the second example it doesn't make sense to buy travel cards. Note that each of Polycarp trip (except the first) was made with transshipment. So the minimum total sum equals to 2 + 1 + 1 + 1 = 5 burles.


Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food.

Iahub asks Iahubina: can you build a rooted tree, such that

  each internal node (a node with at least one son) has at least two sons;  node i has c_{i} nodes in its subtree?

Iahubina has to guess the tree. Being a smart girl, she realized that it's possible no tree can follow Iahub's restrictions. In this way, Iahub will eat all the food. You need to help Iahubina: determine if there's at least one tree following Iahub's restrictions. The required tree must contain n nodes.

-----Input-----

The first line of the input contains integer n (1 ≤ n ≤ 24). Next line contains n positive integers: the i-th number represents c_{i} (1 ≤ c_{i} ≤ n).

-----Output-----

Output on the first line "YES" (without quotes) if there exist at least one tree following Iahub's restrictions, otherwise output "NO" (without quotes).

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

Output
YES
Input
5
1 1 5 2 1

Output
NO


Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.

Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.

Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.

-----Input-----

The first line contains a single integer n (2 ≤ n ≤ 100) — the number of days for which the average air temperature is known.

The second line contains a sequence of integers t_1, t_2, ..., t_{n} ( - 1000 ≤ t_{i} ≤ 1000) — where t_{i} is the average temperature in the i-th day.

-----Output-----

Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.

-----Examples-----
Input
5
10 5 0 -5 -10

Output
-15

Input
4
1 1 1 1

Output
1

Input
3
5 1 -5

Output
-5

Input
2
900 1000

Output
1100

-----Note-----

In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is  - 10 - 5 =  - 15.

In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.

In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to  - 5.

In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.


Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.

You are given a tree with $n$ nodes. In the beginning, $0$ is written on all edges. In one operation, you can choose any $2$ distinct leaves $u$, $v$ and any real number $x$ and add $x$ to values written on all edges on the simple path between $u$ and $v$.

For example, on the picture below you can see the result of applying two operations to the graph: adding $2$ on the path from $7$ to $6$, and then adding $-0.5$ on the path from $4$ to $5$.

 [Image]

Is it true that for any configuration of real numbers written on edges, we can achieve it with a finite number of operations?

Leaf is a node of a tree of degree $1$. Simple path is a path that doesn't contain any node twice.

-----Input-----

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

Each of the next $n-1$ lines contains two integers $u$ and $v$ ($1 \le u, v \le n$, $u \neq v$), meaning that there is an edge between nodes $u$ and $v$. It is guaranteed that these edges form a tree.

-----Output-----

If there is a configuration of real numbers written on edges of the tree that we can't achieve by performing the operations, output "NO".

Otherwise, output "YES".

You can print each letter in any case (upper or lower).

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

Output
YES
Input
3
1 2
2 3

Output
NO
Input
5
1 2
1 3
1 4
2 5

Output
NO
Input
6
1 2
1 3
1 4
2 5
2 6

Output
YES

-----Note-----

In the first example, we can add any real $x$ to the value written on the only edge $(1, 2)$.

 [Image]

In the second example, one of configurations that we can't reach is $0$ written on $(1, 2)$ and $1$ written on $(2, 3)$.

 $8$

Below you can see graphs from examples $3$, $4$:

 [Image]

 [Image]


Boy Dima gave Julian a birthday present — set $B$ consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!

Julian was almost upset, but her friend Alex said, that he can build an undirected graph using this set in such a way: let all integer numbers be vertices, then connect any two $i$ and $j$ with an edge if $|i - j|$ belongs to $B$.

Unfortunately, Julian doesn't like the graph, that was built using $B$. Alex decided to rectify the situation, so he wants to erase some numbers from $B$, so that graph built using the new set is bipartite. The difficulty of this task is that the graph, Alex has to work with, has an infinite number of vertices and edges! It is impossible to solve this task alone, so Alex asks you for help. Write a program that erases a subset of minimum size from $B$ so that graph constructed on the new set is bipartite.

Recall, that graph is bipartite if all its vertices can be divided into two disjoint sets such that every edge connects a vertex from different sets.

-----Input-----

First line contains an integer $n ~ (1 \leqslant n \leqslant 200\,000)$ — size of $B$

Second line contains $n$ integers $b_1, b_2, \ldots, b_n ~ (1 \leqslant b_i \leqslant 10^{18})$ — numbers of $B$, all $b_i$ are unique

-----Output-----

In the first line print single integer $k$ – the number of erased elements. In the second line print $k$ integers — values of erased elements.

If there are multiple answers, print any of them.

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

Output
1
2
Input
2
2 6

Output
0


We have a board with a 2 \times N grid.
Snuke covered the board with N dominoes without overlaps.
Here, a domino can cover a 1 \times 2 or 2 \times 1 square.
Then, Snuke decided to paint these dominoes using three colors: red, cyan and green.
Two dominoes that are adjacent by side should be painted by different colors.
Here, it is not always necessary to use all three colors.
Find the number of such ways to paint the dominoes, modulo 1000000007.
The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner:
 - Each domino is represented by a different English letter (lowercase or uppercase).
 - The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

-----Constraints-----
 - 1 \leq N \leq 52
 - |S_1| = |S_2| = N
 - S_1 and S_2 consist of lowercase and uppercase English letters.
 - S_1 and S_2 represent a valid arrangement of dominoes.

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

-----Output-----
Print the number of such ways to paint the dominoes, modulo 1000000007.

-----Sample Input-----
3
aab
ccb

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

There are six ways as shown below:


Consider a table G of size n × m such that G(i, j) = GCD(i, j) for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. GCD(a, b) is the greatest common divisor of numbers a and b.

You have a sequence of positive integer numbers a_1, a_2, ..., a_{k}. We say that this sequence occurs in table G if it coincides with consecutive elements in some row, starting from some position. More formally, such numbers 1 ≤ i ≤ n and 1 ≤ j ≤ m - k + 1 should exist that G(i, j + l - 1) = a_{l} for all 1 ≤ l ≤ k.

Determine if the sequence a occurs in table G.

-----Input-----

The first line contains three space-separated integers n, m and k (1 ≤ n, m ≤ 10^12; 1 ≤ k ≤ 10000). The second line contains k space-separated integers a_1, a_2, ..., a_{k} (1 ≤ a_{i} ≤ 10^12).

-----Output-----

Print a single word "YES", if the given sequence occurs in table G, otherwise print "NO".

-----Examples-----
Input
100 100 5
5 2 1 2 1

Output
YES

Input
100 8 5
5 2 1 2 1

Output
NO

Input
100 100 7
1 2 3 4 5 6 7

Output
NO

-----Note-----

Sample 1. The tenth row of table G starts from sequence {1, 2, 1, 2, 5, 2, 1, 2, 1, 10}. As you can see, elements from fifth to ninth coincide with sequence a.

Sample 2. This time the width of table G equals 8. Sequence a doesn't occur there.


There is a square grid of size $n \times n$. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs $\min(h, w)$ to color a rectangle of size $h \times w$. You are to make all cells white for minimum total cost.

The square is large, so we give it to you in a compressed way. The set of black cells is the union of $m$ rectangles.

-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n \le 10^{9}$, $0 \le m \le 50$) — the size of the square grid and the number of black rectangles.

Each of the next $m$ lines contains 4 integers $x_{i1}$ $y_{i1}$ $x_{i2}$ $y_{i2}$ ($1 \le x_{i1} \le x_{i2} \le n$, $1 \le y_{i1} \le y_{i2} \le n$) — the coordinates of the bottom-left and the top-right corner cells of the $i$-th black rectangle.

The rectangles may intersect.

-----Output-----

Print a single integer — the minimum total cost of painting the whole square in white.

-----Examples-----
Input
10 2
4 1 5 10
1 4 10 5

Output
4

Input
7 6
2 1 2 1
4 2 4 3
2 5 2 5
2 3 5 3
1 2 1 2
3 2 5 3

Output
3

-----Note-----

The examples and some of optimal solutions are shown on the pictures below.

 [Image]


Slime has a sequence of positive integers $a_1, a_2, \ldots, a_n$.

In one operation Orac can choose an arbitrary subsegment $[l \ldots r]$ of this sequence and replace all values $a_l, a_{l + 1}, \ldots, a_r$ to the value of median of $\{a_l, a_{l + 1}, \ldots, a_r\}$.

In this problem, for the integer multiset $s$, the median of $s$ is equal to the $\lfloor \frac{|s|+1}{2}\rfloor$-th smallest number in it. For example, the median of $\{1,4,4,6,5\}$ is $4$, and the median of $\{1,7,5,8\}$ is $5$.

Slime wants Orac to make $a_1 = a_2 = \ldots = a_n = k$ using these operations.

Orac thinks that it is impossible, and he does not want to waste his time, so he decided to ask you if it is possible to satisfy the Slime's requirement, he may ask you these questions several times.

-----Input-----

The first line of the input is a single integer $t$: the number of queries.

The first line of each query contains two integers $n\ (1\le n\le 100\,000)$ and $k\ (1\le k\le 10^9)$, the second line contains $n$ positive integers $a_1,a_2,\dots,a_n\ (1\le a_i\le 10^9)$

The total sum of $n$ is at most $100\,000$.

-----Output-----

The output should contain $t$ lines. The $i$-th line should be equal to 'yes' if it is possible to make all integers $k$ in some number of operations or 'no', otherwise. You can print each letter in lowercase or uppercase.

-----Example-----
Input
5
5 3
1 5 2 6 1
1 6
6
3 2
1 2 3
4 3
3 1 2 3
10 3
1 2 3 4 5 6 7 8 9 10

Output
no
yes
yes
no
yes

-----Note-----

In the first query, Orac can't turn all elements into $3$.

In the second query, $a_1=6$ is already satisfied.

In the third query, Orac can select the complete array and turn all elements into $2$.

In the fourth query, Orac can't turn all elements into $3$.

In the fifth query, Orac can select $[1,6]$ at first and then select $[2,10]$.


Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special.

Alyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with two integers l_{i} and r_{i}, and its elements are a[l_{i}], a[l_{i} + 1], ..., a[r_{i}].

Alyona is going to find mex for each of the chosen subarrays. Among these m mexes the girl is going to find the smallest. She wants this minimum mex to be as large as possible.

You are to find an array a of n elements so that the minimum mex among those chosen by Alyona subarrays is as large as possible.

The mex of a set S is a minimum possible non-negative integer that is not in S.

-----Input-----

The first line contains two integers n and m (1 ≤ n, m ≤ 10^5).

The next m lines contain information about the subarrays chosen by Alyona. The i-th of these lines contains two integers l_{i} and r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n), that describe the subarray a[l_{i}], a[l_{i} + 1], ..., a[r_{i}].

-----Output-----

In the first line print single integer — the maximum possible minimum mex.

In the second line print n integers — the array a. All the elements in a should be between 0 and 10^9.

It is guaranteed that there is an optimal answer in which all the elements in a are between 0 and 10^9.

If there are multiple solutions, print any of them.

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

Output
2
1 0 2 1 0

Input
4 2
1 4
2 4

Output
3
5 2 0 1

-----Note-----

The first example: the mex of the subarray (1, 3) is equal to 3, the mex of the subarray (2, 5) is equal to 3, the mex of the subarray (4, 5) is equal to 2 as well, thus the minumal mex among the subarrays chosen by Alyona is equal to 2.


Moriarty has trapped n people in n distinct rooms in a hotel. Some rooms are locked, others are unlocked. But, there is a condition that the people in the hotel can only escape when all the doors are unlocked at the same time. There are m switches. Each switch control doors of some rooms, but each door is controlled by exactly two switches.

You are given the initial configuration of the doors. Toggling any switch, that is, turning it ON when it is OFF, or turning it OFF when it is ON, toggles the condition of the doors that this switch controls. Say, we toggled switch 1, which was connected to room 1, 2 and 3 which were respectively locked, unlocked and unlocked. Then, after toggling the switch, they become unlocked, locked and locked.

You need to tell Sherlock, if there exists a way to unlock all doors at the same time.

-----Input-----

First line of input contains two integers n and m (2 ≤ n ≤ 10^5, 2 ≤ m ≤ 10^5) — the number of rooms and the number of switches.

Next line contains n space-separated integers r_1, r_2, ..., r_{n} (0 ≤ r_{i} ≤ 1) which tell the status of room doors. The i-th room is locked if r_{i} = 0, otherwise it is unlocked.

The i-th of next m lines contains an integer x_{i} (0 ≤ x_{i} ≤ n) followed by x_{i} distinct integers separated by space, denoting the number of rooms controlled by the i-th switch followed by the room numbers that this switch controls. It is guaranteed that the room numbers are in the range from 1 to n. It is guaranteed that each door is controlled by exactly two switches.

-----Output-----

Output "YES" without quotes, if it is possible to open all doors at the same time, otherwise output "NO" without quotes.

-----Examples-----
Input
3 3
1 0 1
2 1 3
2 1 2
2 2 3

Output
NO
Input
3 3
1 0 1
3 1 2 3
1 2
2 1 3

Output
YES
Input
3 3
1 0 1
3 1 2 3
2 1 2
1 3

Output
NO

-----Note-----

In the second example input, the initial statuses of the doors are [1, 0, 1] (0 means locked, 1 — unlocked).

After toggling switch 3, we get [0, 0, 0] that means all doors are locked.

Then, after toggling switch 1, we get [1, 1, 1] that means all doors are unlocked.

It can be seen that for the first and for the third example inputs it is not possible to make all doors unlocked.


Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that the goal is to replace each '#' with one or more ')' characters so that the final string becomes beautiful.

Below there was also written that a string is called beautiful if for each i (1 ≤ i ≤ |s|) there are no more ')' characters than '(' characters among the first i characters of s and also the total number of '(' characters is equal to the total number of ')' characters.

Help Malek open the door by telling him for each '#' character how many ')' characters he must replace it with.

-----Input-----

The first line of the input contains a string s (1 ≤ |s| ≤ 10^5). Each character of this string is one of the characters '(', ')' or '#'. It is guaranteed that s contains at least one '#' character.

-----Output-----

If there is no way of replacing '#' characters which leads to a beautiful string print  - 1. Otherwise for each character '#' print a separate line containing a positive integer, the number of ')' characters this character must be replaced with.

If there are several possible answers, you may output any of them.

-----Examples-----
Input
(((#)((#)

Output
1
2

Input
()((#((#(#()

Output
2
2
1
Input
#

Output
-1

Input
(#)

Output
-1

-----Note-----

|s| denotes the length of the string s.


User ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below.  At first, the score is 0.  For each block of contiguous "o"s with length x the score increases by x^2.  For each block of contiguous "x"s with length y the score decreases by y^2.

For example, if a = 6, b = 3 and ainta have arranged the cards in the order, that is described by string "ooxoooxxo", the score of the deck equals 2^2 - 1^2 + 3^2 - 2^2 + 1^2 = 9. That is because the deck has 5 blocks in total: "oo", "x", "ooo", "xx", "o".

User ainta likes big numbers, so he wants to maximize the score with the given cards. Help ainta make the score as big as possible. Note, that he has to arrange all his cards.

-----Input-----

The first line contains two space-separated integers a and b (0 ≤ a, b ≤ 10^5; a + b ≥ 1) — the number of "o" cards and the number of "x" cards.

-----Output-----

In the first line print a single integer v — the maximum score that ainta can obtain.

In the second line print a + b characters describing the deck. If the k-th card of the deck contains "o", the k-th character must be "o". If the k-th card of the deck contains "x", the k-th character must be "x". The number of "o" characters must be equal to a, and the number of "x " characters must be equal to b. If there are many ways to maximize v, print any.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

-----Examples-----
Input
2 3

Output
-1
xoxox

Input
4 0

Output
16
oooo
Input
0 4

Output
-16
xxxx


Alice, Bob and Charlie are playing Card Game for Three, as below:
 - At first, each of the three players has a deck consisting of some number of cards. Alice's deck has N cards, Bob's deck has M cards, and Charlie's deck has K cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.
 - The players take turns. Alice goes first.
 - If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)
 - If the current player's deck is empty, the game ends and the current player wins the game.
There are 3^{N+M+K} possible patters of the three player's initial decks. Among these patterns, how many will lead to Alice's victory?
Since the answer can be large, print the count modulo 1\,000\,000\,007 (=10^9+7).

-----Constraints-----
 - 1 \leq N \leq 3×10^5
 - 1 \leq M \leq 3×10^5
 - 1 \leq K \leq 3×10^5

-----Partial Scores-----
 - 500 points will be awarded for passing the test set satisfying the following: 1 \leq N \leq 1000, 1 \leq M \leq 1000, 1 \leq K \leq 1000.

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

-----Output-----
Print the answer modulo 1\,000\,000\,007 (=10^9+7).

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

-----Sample Output-----
17

 - If Alice's card is a, then Alice will win regardless of Bob's and Charlie's card. There are 3×3=9 such patterns.
 - If Alice's card is b, Alice will only win when Bob's card is a, or when Bob's card is c and Charlie's card is a. There are 3+1=4 such patterns.
 - If Alice's card is c, Alice will only win when Charlie's card is a, or when Charlie's card is b and Bob's card is a. There are 3+1=4 such patterns.
Thus, there are total of 9+4+4=17 patterns that will lead to Alice's victory.


Dora loves adventures quite a lot. During some journey she encountered an amazing city, which is formed by $n$ streets along the Eastern direction and $m$ streets across the Southern direction. Naturally, this city has $nm$ intersections. At any intersection of $i$-th Eastern street and $j$-th Southern street there is a monumental skyscraper. Dora instantly became curious and decided to explore the heights of the city buildings.

When Dora passes through the intersection of the $i$-th Eastern and $j$-th Southern street she examines those two streets. After Dora learns the heights of all the skyscrapers on those two streets she wonders: how one should reassign heights to the skyscrapers on those two streets, so that the maximum height would be as small as possible and the result of comparing the heights of any two skyscrapers on one street wouldn't change.

Formally, on every of $nm$ intersections Dora solves an independent problem. She sees $n + m - 1$ skyscrapers and for each of them she knows its real height. Moreover, any two heights can be compared to get a result "greater", "smaller" or "equal". Now Dora wants to select some integer $x$ and assign every skyscraper a height from $1$ to $x$. When assigning heights, Dora wants to preserve the relative order of the skyscrapers in both streets. That is, the result of any comparison of heights of two skyscrapers in the current Eastern street shouldn't change and the result of any comparison of heights of two skyscrapers in current Southern street shouldn't change as well. Note that skyscrapers located on the Southern street are not compared with skyscrapers located on the Eastern street only. However, the skyscraper located at the streets intersection can be compared with both Southern and Eastern skyscrapers. For every intersection Dora wants to independently calculate the minimum possible $x$.

For example, if the intersection and the two streets corresponding to it look as follows: [Image]

Then it is optimal to replace the heights of the skyscrapers as follows (note that all comparisons "less", "equal", "greater" inside the Eastern street and inside the Southern street are preserved) [Image]

The largest used number is $5$, hence the answer for this intersection would be $5$.

Help Dora to compute the answers for each intersection.

-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n, m \le 1000$) — the number of streets going in the Eastern direction and the number of the streets going in Southern direction.

Each of the following $n$ lines contains $m$ integers $a_{i,1}$, $a_{i,2}$, ..., $a_{i,m}$ ($1 \le a_{i,j} \le 10^9$). The integer $a_{i,j}$, located on $j$-th position in the $i$-th line denotes the height of the skyscraper at the intersection of the $i$-th Eastern street and $j$-th Southern direction.

-----Output-----

Print $n$ lines containing $m$ integers each. The integer $x_{i,j}$, located on $j$-th position inside the $i$-th line is an answer for the problem at the intersection of $i$-th Eastern street and $j$-th Southern street.

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

Output
2 2 2
2 2 2

Input
2 2
1 2
3 4

Output
2 3
3 2

-----Note-----

In the first example, it's not possible to decrease the maximum used height for the problem at any intersection, hence we don't have to change any heights.

In the second example, the answers are as follows:   For the intersection of the first line and the first column [Image] For the intersection of the first line and the second column [Image] For the intersection of the second line and the first column [Image] For the intersection of the second line and the second column [Image]


The only difference between easy and hard versions is constraints.

Nauuo is a girl who loves random picture websites.

One day she made a random picture website by herself which includes $n$ pictures.

When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal probability. The $i$-th picture has a non-negative weight $w_i$, and the probability of the $i$-th picture being displayed is $\frac{w_i}{\sum_{j=1}^nw_j}$. That is to say, the probability of a picture to be displayed is proportional to its weight.

However, Nauuo discovered that some pictures she does not like were displayed too often.

To solve this problem, she came up with a great idea: when she saw a picture she likes, she would add $1$ to its weight; otherwise, she would subtract $1$ from its weight.

Nauuo will visit the website $m$ times. She wants to know the expected weight of each picture after all the $m$ visits modulo $998244353$. Can you help her?

The expected weight of the $i$-th picture can be denoted by $\frac {q_i} {p_i}$ where $\gcd(p_i,q_i)=1$, you need to print an integer $r_i$ satisfying $0\le r_i<998244353$ and $r_i\cdot p_i\equiv q_i\pmod{998244353}$. It can be proved that such $r_i$ exists and is unique.

-----Input-----

The first line contains two integers $n$ and $m$ ($1\le n\le 2\cdot 10^5$, $1\le m\le 3000$) — the number of pictures and the number of visits to the website.

The second line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($a_i$ is either $0$ or $1$) — if $a_i=0$ , Nauuo does not like the $i$-th picture; otherwise Nauuo likes the $i$-th picture. It is guaranteed that there is at least one picture which Nauuo likes.

The third line contains $n$ positive integers $w_1,w_2,\ldots,w_n$ ($w_i \geq 1$) — the initial weights of the pictures. It is guaranteed that the sum of all the initial weights does not exceed $998244352-m$.

-----Output-----

The output contains $n$ integers $r_1,r_2,\ldots,r_n$ — the expected weights modulo $998244353$.

-----Examples-----
Input
2 1
0 1
2 1

Output
332748119
332748119

Input
1 2
1
1

Output
3

Input
3 3
0 1 1
4 3 5

Output
160955686
185138929
974061117

-----Note-----

In the first example, if the only visit shows the first picture with a probability of $\frac 2 3$, the final weights are $(1,1)$; if the only visit shows the second picture with a probability of $\frac1 3$, the final weights are $(2,2)$.

So, both expected weights are $\frac2 3\cdot 1+\frac 1 3\cdot 2=\frac4 3$ .

Because $332748119\cdot 3\equiv 4\pmod{998244353}$, you need to print $332748119$ instead of $\frac4 3$ or $1.3333333333$.

In the second example, there is only one picture which Nauuo likes, so every time Nauuo visits the website, $w_1$ will be increased by $1$.

So, the expected weight is $1+2=3$.

Nauuo is very naughty so she didn't give you any hint of the third example.


Artem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each move goes like this. Artem chooses some element of the array and removes it. For that, he gets min(a, b) points, where a and b are numbers that were adjacent with the removed number. If the number doesn't have an adjacent number to the left or right, Artem doesn't get any points.

After the element is removed, the two parts of the array glue together resulting in the new array that Artem continues playing with. Borya wondered what maximum total number of points Artem can get as he plays this game.

-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 5·10^5) — the number of elements in the array. The next line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the values of the array elements.

-----Output-----

In a single line print a single integer — the maximum number of points Artem can get.

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

Output
11

Input
5
1 2 3 4 5

Output
6

Input
5
1 100 101 100 1

Output
102


Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least $3$ (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself $k$-multihedgehog.

Let us define $k$-multihedgehog as follows: $1$-multihedgehog is hedgehog: it has one vertex of degree at least $3$ and some vertices of degree 1. For all $k \ge 2$, $k$-multihedgehog is $(k-1)$-multihedgehog in which the following changes has been made for each vertex $v$ with degree 1: let $u$ be its only neighbor; remove vertex $v$, create a new hedgehog with center at vertex $w$ and connect vertices $u$ and $w$ with an edge. New hedgehogs can differ from each other and the initial gift.

Thereby $k$-multihedgehog is a tree. Ivan made $k$-multihedgehog but he is not sure that he did not make any mistakes. That is why he asked you to check if his tree is indeed $k$-multihedgehog.

-----Input-----

First line of input contains $2$ integers $n$, $k$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{9}$) — number of vertices and hedgehog parameter.

Next $n-1$ lines contains two integers $u$ $v$ ($1 \le u, \,\, v \le n; \,\, u \ne v$) — indices of vertices connected by edge.

It is guaranteed that given graph is a tree.

-----Output-----

Print "Yes" (without quotes), if given graph is $k$-multihedgehog, and "No" (without quotes) otherwise.

-----Examples-----
Input
14 2
1 4
2 4
3 4
4 13
10 5
11 5
12 5
14 5
5 13
6 7
8 6
13 6
9 6

Output
Yes

Input
3 1
1 3
2 3

Output
No

-----Note-----

2-multihedgehog from the first example looks like this:

[Image]

Its center is vertex $13$. Hedgehogs created on last step are: [4 (center), 1, 2, 3], [6 (center), 7, 8, 9], [5 (center), 10, 11, 12, 13].

Tree from second example is not a hedgehog because degree of center should be at least $3$.


A monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care.

There is an $n\times m$ grid. Initially, you may place some north magnets and some south magnets into the cells. You are allowed to place as many magnets as you like, even multiple in the same cell.

An operation is performed as follows. Choose a north magnet and a south magnet to activate. If they are in the same row or the same column and they occupy different cells, then the north magnet moves one unit closer to the south magnet. Otherwise, if they occupy the same cell or do not share a row or column, then nothing changes. Note that the south magnets are immovable.

Each cell of the grid is colored black or white. Let's consider ways to place magnets in the cells so that the following conditions are met.

  There is at least one south magnet in every row and every column.  If a cell is colored black, then it is possible for a north magnet to occupy this cell after some sequence of operations from the initial placement.  If a cell is colored white, then it is impossible for a north magnet to occupy this cell after some sequence of operations from the initial placement.

Determine if it is possible to place magnets such that these conditions are met. If it is possible, find the minimum number of north magnets required (there are no requirements on the number of south magnets).

-----Input-----

The first line contains two integers $n$ and $m$ ($1\le n,m\le 1000$)  — the number of rows and the number of columns, respectively.

The next $n$ lines describe the coloring. The $i$-th of these lines contains a string of length $m$, where the $j$-th character denotes the color of the cell in row $i$ and column $j$. The characters "#" and "." represent black and white, respectively. It is guaranteed, that the string will not contain any other characters.

-----Output-----

Output a single integer, the minimum possible number of north magnets required.

If there is no placement of magnets that satisfies all conditions, print a single integer $-1$.

-----Examples-----
Input
3 3
.#.
###
##.

Output
1

Input
4 2
##
.#
.#
##

Output
-1

Input
4 5
....#
####.
.###.
.#...

Output
2

Input
2 1
.
#

Output
-1

Input
3 5
.....
.....
.....

Output
0

-----Note-----

In the first test, here is an example placement of magnets:

 [Image]

In the second test, we can show that no required placement of magnets exists. Here are three example placements that fail to meet the requirements. The first example violates rule $3$ since we can move the north magnet down onto a white square. The second example violates rule $2$ since we cannot move the north magnet to the bottom-left black square by any sequence of operations. The third example violates rule $1$ since there is no south magnet in the first column.

 [Image]

In the third test, here is an example placement of magnets. We can show that there is no required placement of magnets with fewer north magnets.

 [Image]

In the fourth test, we can show that no required placement of magnets exists. Here are two example placements that fail to meet the requirements. The first example violates rule $1$ since there is no south magnet in the first row. The second example violates rules $1$ and $3$ since there is no south magnet in the second row and we can move the north magnet up one unit onto a white square.

 [Image]

In the fifth test, we can put the south magnet in each cell and no north magnets. Because there are no black cells, it will be a correct placement.


Initially there was an array $a$ consisting of $n$ integers. Positions in it are numbered from $1$ to $n$.

Exactly $q$ queries were performed on the array. During the $i$-th query some segment $(l_i, r_i)$ $(1 \le l_i \le r_i \le n)$ was selected and values of elements on positions from $l_i$ to $r_i$ inclusive got changed to $i$. The order of the queries couldn't be changed and all $q$ queries were applied. It is also known that every position from $1$ to $n$ got covered by at least one segment.

We could have offered you the problem about checking if some given array (consisting of $n$ integers with values from $1$ to $q$) can be obtained by the aforementioned queries. However, we decided that it will come too easy for you.

So the enhancement we introduced to it is the following. Some set of positions (possibly empty) in this array is selected and values of elements on these positions are set to $0$.

Your task is to check if this array can be obtained by the aforementioned queries. Also if it can be obtained then restore this array.

If there are multiple possible arrays then print any of them.

-----Input-----

The first line contains two integers $n$ and $q$ ($1 \le n, q \le 2 \cdot 10^5$) — the number of elements of the array and the number of queries perfomed on it.

The second line contains $n$ integer numbers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le q$) — the resulting array. If element at some position $j$ is equal to $0$ then the value of element at this position can be any integer from $1$ to $q$.

-----Output-----

Print "YES" if the array $a$ can be obtained by performing $q$ queries. Segments $(l_i, r_i)$ $(1 \le l_i \le r_i \le n)$ are chosen separately for each query. Every position from $1$ to $n$ should be covered by at least one segment.

Otherwise print "NO".

If some array can be obtained then print $n$ integers on the second line — the $i$-th number should be equal to the $i$-th element of the resulting array and should have value from $1$ to $q$. This array should be obtainable by performing exactly $q$ queries.

If there are multiple possible arrays then print any of them.

-----Examples-----
Input
4 3
1 0 2 3

Output
YES
1 2 2 3

Input
3 10
10 10 10

Output
YES
10 10 10

Input
5 6
6 5 6 2 2

Output
NO

Input
3 5
0 0 0

Output
YES
5 4 2

-----Note-----

In the first example you can also replace $0$ with $1$ but not with $3$.

In the second example it doesn't really matter what segments to choose until query $10$ when the segment is $(1, 3)$.

The third example showcases the fact that the order of queries can't be changed, you can't firstly set $(1, 3)$ to $6$ and after that change $(2, 2)$ to $5$. The segment of $5$ should be applied before segment of $6$.

There is a lot of correct resulting arrays for the fourth example.


The GCD table G of size n × n for an array of positive integers a of length n is defined by formula  $g_{ij} = \operatorname{gcd}(a_{i}, a_{j})$

Let us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both x and y, it is denoted as $\operatorname{gcd}(x, y)$. For example, for array a = {4, 3, 6, 2} of length 4 the GCD table will look as follows: [Image]

Given all the numbers of the GCD table G, restore array a.

-----Input-----

The first line contains number n (1 ≤ n ≤ 500) — the length of array a. The second line contains n^2 space-separated numbers — the elements of the GCD table of G for array a.

All the numbers in the table are positive integers, not exceeding 10^9. Note that the elements are given in an arbitrary order. It is guaranteed that the set of the input data corresponds to some array a.

-----Output-----

In the single line print n positive integers — the elements of array a. If there are multiple possible solutions, you are allowed to print any of them.

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

Output
4 3 6 2
Input
1
42

Output
42
Input
2
1 1 1 1

Output
1 1


There are $n$ points on the plane, the $i$-th of which is at $(x_i, y_i)$. Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area.

The strange area is enclosed by three lines, $x = l$, $y = a$ and $x = r$, as its left side, its bottom side and its right side respectively, where $l$, $r$ and $a$ can be any real numbers satisfying that $l < r$. The upper side of the area is boundless, which you can regard as a line parallel to the $x$-axis at infinity. The following figure shows a strange rectangular area. [Image]

A point $(x_i, y_i)$ is in the strange rectangular area if and only if $l < x_i < r$ and $y_i > a$. For example, in the above figure, $p_1$ is in the area while $p_2$ is not.

Tokitsukaze wants to know how many different non-empty sets she can obtain by picking all the points in a strange rectangular area, where we think two sets are different if there exists at least one point in one set of them but not in the other.

-----Input-----

The first line contains a single integer $n$ ($1 \leq n \leq 2 \times 10^5$) — the number of points on the plane.

The $i$-th of the next $n$ lines contains two integers $x_i$, $y_i$ ($1 \leq x_i, y_i \leq 10^9$) — the coordinates of the $i$-th point.

All points are distinct.

-----Output-----

Print a single integer — the number of different non-empty sets of points she can obtain.

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

Output
3

Input
3
1 1
2 1
3 1

Output
6

Input
4
2 1
2 2
3 1
3 2

Output
6

-----Note-----

For the first example, there is exactly one set having $k$ points for $k = 1, 2, 3$, so the total number is $3$.

For the second example, the numbers of sets having $k$ points for $k = 1, 2, 3$ are $3$, $2$, $1$ respectively, and their sum is $6$.

For the third example, as the following figure shows, there are  $2$ sets having one point;  $3$ sets having two points;  $1$ set having four points.

Therefore, the number of different non-empty sets in this example is $2 + 3 + 0 + 1 = 6$. [Image]


You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns are numbered 1 through n from left to right. At the far side of the room lies a door locked with evil magical forces. The following inscriptions are written on the door: The cleaning of all evil will awaken the door!

Being a very senior adventurer, you immediately realize what this means. You notice that every single cell in the grid are initially evil. You should purify all of these cells.

The only method of tile purification known to you is by casting the "Purification" spell. You cast this spell on a single tile — then, all cells that are located in the same row and all cells that are located in the same column as the selected tile become purified (including the selected tile)! It is allowed to purify a cell more than once.

You would like to purify all n × n cells while minimizing the number of times you cast the "Purification" spell. This sounds very easy, but you just noticed that some tiles are particularly more evil than the other tiles. You cannot cast the "Purification" spell on those particularly more evil tiles, not even after they have been purified. They can still be purified if a cell sharing the same row or the same column gets selected by the "Purification" spell.

Please find some way to purify all the cells with the minimum number of spells cast. Print -1 if there is no such way.

-----Input-----

The first line will contain a single integer n (1 ≤ n ≤ 100). Then, n lines follows, each contains n characters. The j-th character in the i-th row represents the cell located at row i and column j. It will be the character 'E' if it is a particularly more evil cell, and '.' otherwise.

-----Output-----

If there exists no way to purify all the cells, output -1. Otherwise, if your solution casts x "Purification" spells (where x is the minimum possible number of spells), output x lines. Each line should consist of two integers denoting the row and column numbers of the cell on which you should cast the "Purification" spell.

-----Examples-----
Input
3
.E.
E.E
.E.

Output
1 1
2 2
3 3

Input
3
EEE
E..
E.E

Output
-1

Input
5
EE.EE
E.EE.
E...E
.EE.E
EE.EE

Output
3 3
1 3
2 2
4 4
5 3

-----Note-----

The first example is illustrated as follows. Purple tiles are evil tiles that have not yet been purified. Red tile is the tile on which "Purification" is cast. Yellow tiles are the tiles being purified as a result of the current "Purification" spell. Green tiles are tiles that have been purified previously.  [Image]

In the second example, it is impossible to purify the cell located at row 1 and column 1.

For the third example: [Image]


As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:

$f(a, l, r) = \sum_{i = l}^{r} a [ i ] ; m(a) = \operatorname{max}_{1 \leq l \leq r \leq n} f(a, l, r)$

A swap operation is the following sequence of actions:

  choose two indexes i, j (i ≠ j);  perform assignments tmp = a[i], a[i] = a[j], a[j] = tmp.

What maximum value of function m(a) can Sereja get if he is allowed to perform at most k swap operations?

-----Input-----

The first line contains two integers n and k (1 ≤ n ≤ 200; 1 ≤ k ≤ 10). The next line contains n integers a[1], a[2], ..., a[n] ( - 1000 ≤ a[i] ≤ 1000).

-----Output-----

In a single line print the maximum value of m(a) that Sereja can get if he is allowed to perform at most k swap operations.

-----Examples-----
Input
10 2
10 -1 2 2 2 2 2 2 -1 10

Output
32

Input
5 10
-1 -1 -1 -1 -1

Output
-1


You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR.

Find the maximum possible value of [Image] after performing at most k operations optimally.

-----Input-----

The first line contains three integers n, k and x (1 ≤ n ≤ 200 000, 1 ≤ k ≤ 10, 2 ≤ x ≤ 8).

The second line contains n integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9).

-----Output-----

Output the maximum value of a bitwise OR of sequence elements after performing operations.

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

Output
3

Input
4 2 3
1 2 4 8

Output
79

-----Note-----

For the first sample, any possible choice of doing one operation will result the same three numbers 1, 1, 2 so the result is $1|1|2 = 3$.

For the second sample if we multiply 8 by 3 two times we'll get 72. In this case the numbers will become 1, 2, 4, 72 so the OR value will be 79 and is the largest possible result.


Takahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.
For each i=2,3,...,2K, find the following value modulo 998244353:
 - The number of combinations of N sides shown by the dice such that the sum of no two different sides is i.
Note that the dice are NOT distinguishable, that is, two combinations are considered different when there exists an integer k such that the number of dice showing k is different in those two.

-----Constraints-----
 - 1 \leq K \leq 2000
 - 2 \leq N \leq 2000
 - K and N are integers.

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

-----Output-----
Print 2K-1 integers. The t-th of them (1\leq t\leq 2K-1) should be the answer for i=t+1.

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

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

 - For i=2, the combinations (1,2,2),(1,2,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.
 - For i=3, the combinations (1,1,1),(1,1,3),(1,3,3),(2,2,2),(2,2,3),(2,3,3),(3,3,3) satisfy the condition, so the answer is 7.
 - For i=4, the combinations (1,1,1),(1,1,2),(2,3,3),(3,3,3) satisfy the condition, so the answer is 4.