Pushok the dog has been chasing Imp for a few hours already. $48$

Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.

While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a lot of noise. We define noise of string t as the number of occurrences of string "sh" as a subsequence in it, in other words, the number of such pairs (i, j), that i < j and $t_{i} = s$ and $t_{j} = h$.

The robot is off at the moment. Imp knows that it has a sequence of strings t_{i} in its memory, and he can arbitrary change their order. When the robot is started, it generates the string t as a concatenation of these strings in the given order. The noise of the resulting string equals the noise of this concatenation.

Help Imp to find the maximum noise he can achieve by changing the order of the strings.

-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of strings in robot's memory.

Next n lines contain the strings t_1, t_2, ..., t_{n}, one per line. It is guaranteed that the strings are non-empty, contain only English letters 's' and 'h' and their total length does not exceed 10^5.

-----Output-----

Print a single integer — the maxumum possible noise Imp can achieve by changing the order of the strings.

-----Examples-----
Input
4
ssh
hs
s
hhhs

Output
18

Input
2
h
s

Output
1

-----Note-----

The optimal concatenation in the first sample is ssshhshhhs.


Ayush and Ashish play a game on an unrooted tree consisting of $n$ nodes numbered $1$ to $n$. Players make the following move in turns:   Select any leaf node in the tree and remove it together with any edge which has this node as one of its endpoints. A leaf node is a node with degree less than or equal to $1$.

A tree is a connected undirected graph without cycles.

There is a special node numbered $x$. The player who removes this node wins the game.

Ayush moves first. Determine the winner of the game if each player plays optimally.

-----Input-----

The first line of the input contains a single integer $t$ $(1 \leq t \leq 10)$ — the number of testcases. The description of the test cases follows.

The first line of each testcase contains two integers $n$ and $x$ $(1\leq n \leq 1000, 1 \leq x \leq n)$ — the number of nodes in the tree and the special node respectively.

Each of the next $n-1$ lines contain two integers $u$, $v$ $(1 \leq u, v \leq n, \text{ } u \ne v)$, meaning that there is an edge between nodes $u$ and $v$ in the tree.

-----Output-----

For every test case, if Ayush wins the game, print "Ayush", otherwise print "Ashish" (without quotes).

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

Output
Ashish

Input
1
3 2
1 2
1 3

Output
Ayush

-----Note-----

For the $1$st test case, Ayush can only remove node $2$ or $3$, after which node $1$ becomes a leaf node and Ashish can remove it in his turn.

For the $2$nd test case, Ayush can remove node $2$ in the first move itself.


Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is described by a group of three (p, l, r), where p is a string and l and r (l ≤ r) are integers. We’ll say that string t complies with rule (p, l, r), if the number of occurrences of string t in string p lies between l and r, inclusive. For example, string "ab", complies with rules ("ab", 1, 2) and ("aab", 0, 1), but does not comply with rules ("cd", 1, 2) and ("abab", 0, 1).

A substring s[l... r] (1 ≤ l ≤ r ≤ |s|) of string s = s_1s_2... s_{|}s| (|s| is a length of s) is string s_{l}s_{l} + 1... s_{r}.

Consider a number of occurrences  of string t in string p as a number of pairs of integers l, r (1 ≤ l ≤ r ≤ |p|) such that p[l... r] = t.

We’ll say that string t is good if it complies with all n rules. Smart Beaver asks you to help him to write a program that can calculate the number of distinct good substrings of string s. Two substrings s[x... y] and s[z... w] are cosidered to be distinct iff s[x... y] ≠ s[z... w].

-----Input-----

The first line contains string s. The second line contains integer n. Next n lines contain the rules, one per line. Each of these lines contains a string and two integers p_{i}, l_{i}, r_{i}, separated by single spaces (0 ≤ l_{i} ≤ r_{i} ≤ |p_{i}|). It is guaranteed that all the given strings are non-empty and only contain lowercase English letters.

The input limits for scoring 30 points are (subproblem G1):   0 ≤ n ≤ 10.  The length of string s and the maximum length of string p is  ≤ 200.

The input limits for scoring 70 points are (subproblems G1+G2):   0 ≤ n ≤ 10.  The length of string s and the maximum length of string p is  ≤ 2000.

The input limits for scoring 100 points are (subproblems G1+G2+G3):   0 ≤ n ≤ 10.  The length of string s and the maximum length of string p is  ≤ 50000.

-----Output-----

Print a single integer — the number of good substrings of string s.

-----Examples-----
Input
aaab
2
aa 0 0
aab 1 1

Output
3

Input
ltntlnen
3
n 0 0
ttlneenl 1 4
lelllt 1 1

Output
2

Input
a
0

Output
1

-----Note-----

There are three good substrings in the first sample test: «aab», «ab» and «b».

In the second test only substrings «e» and «t» are good.


Find an n × n matrix with different numbers from 1 to n^2, so the sum in each row, column and both main diagonals are odd.

-----Input-----

The only line contains odd integer n (1 ≤ n ≤ 49).

-----Output-----

Print n lines with n integers. All the integers should be different and from 1 to n^2. The sum in each row, column and both main diagonals should be odd.

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

Output
1

Input
3

Output
2 1 4
3 5 7
6 9 8


Iahub wants to enhance his multitasking abilities. In order to do this, he wants to sort n arrays simultaneously, each array consisting of m integers.

Iahub can choose a pair of distinct indices i and j (1 ≤ i, j ≤ m, i ≠ j). Then in each array the values at positions i and j are swapped only if the value at position i is strictly greater than the value at position j.

Iahub wants to find an array of pairs of distinct indices that, chosen in order, sort all of the n arrays in ascending or descending order (the particular order is given in input). The size of the array can be at most $\frac{m(m - 1)}{2}$ (at most $\frac{m(m - 1)}{2}$ pairs). Help Iahub, find any suitable array.

-----Input-----

The first line contains three integers n (1 ≤  n ≤ 1000), m (1 ≤ m ≤  100) and k. Integer k is 0 if the arrays must be sorted in ascending order, and 1 if the arrays must be sorted in descending order. Each line i of the next n lines contains m integers separated by a space, representing the i-th array. For each element x of the array i, 1 ≤ x ≤ 10^6 holds.

-----Output-----

On the first line of the output print an integer p, the size of the array (p can be at most $\frac{m(m - 1)}{2}$). Each of the next p lines must contain two distinct integers i and j (1 ≤ i, j ≤ m, i ≠ j), representing the chosen indices.

If there are multiple correct answers, you can print any.

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

Output
3
2 4
2 3
4 5

Input
3 2 1
1 2
2 3
3 4

Output
1
2 1

-----Note-----

Consider the first sample. After the first operation, the arrays become [1, 3, 2, 5, 4] and [1, 2, 3, 4, 5]. After the second operation, the arrays become [1, 2, 3, 5, 4] and [1, 2, 3, 4, 5]. After the third operation they become [1, 2, 3, 4, 5] and [1, 2, 3, 4, 5].


A binary matrix is called good if every even length square sub-matrix has an odd number of ones.

Given a binary matrix $a$ consisting of $n$ rows and $m$ columns, determine the minimum number of cells you need to change to make it good, or report that there is no way to make it good at all.

All the terms above have their usual meanings — refer to the Notes section for their formal definitions.

-----Input-----

The first line of input contains two integers $n$ and $m$ ($1 \leq n \leq m \leq 10^6$ and $n\cdot m \leq 10^6$)  — the number of rows and columns in $a$, respectively.

The following $n$ lines each contain $m$ characters, each of which is one of 0 and 1. If the $j$-th character on the $i$-th line is 1, then $a_{i,j} = 1$. Similarly, if the $j$-th character on the $i$-th line is 0, then $a_{i,j} = 0$.

-----Output-----

Output the minimum number of cells you need to change to make $a$ good, or output $-1$ if it's not possible at all.

-----Examples-----
Input
3 3
101
001
110

Output
2
Input
7 15
000100001010010
100111010110001
101101111100100
010000111111010
111010010100001
000011001111101
111111011010011

Output
-1

-----Note-----

In the first case, changing $a_{1,1}$ to $0$ and $a_{2,2}$ to $1$ is enough.

You can verify that there is no way to make the matrix in the second case good.

Some definitions —   A binary matrix is one in which every element is either $1$ or $0$.  A sub-matrix is described by $4$ parameters — $r_1$, $r_2$, $c_1$, and $c_2$; here, $1 \leq r_1 \leq r_2 \leq n$ and $1 \leq c_1 \leq c_2 \leq m$.  This sub-matrix contains all elements $a_{i,j}$ that satisfy both $r_1 \leq i \leq r_2$ and $c_1 \leq j \leq c_2$.  A sub-matrix is, further, called an even length square if $r_2-r_1 = c_2-c_1$ and $r_2-r_1+1$ is divisible by $2$.


Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition.

There are $n$ flowers in a row in the exhibition. Sonya can put either a rose or a lily in the $i$-th position. Thus each of $n$ positions should contain exactly one flower: a rose or a lily.

She knows that exactly $m$ people will visit this exhibition. The $i$-th visitor will visit all flowers from $l_i$ to $r_i$ inclusive. The girl knows that each segment has its own beauty that is equal to the product of the number of roses and the number of lilies.

Sonya wants her exhibition to be liked by a lot of people. That is why she wants to put the flowers in such way that the sum of beauties of all segments would be maximum possible.

-----Input-----

The first line contains two integers $n$ and $m$ ($1\leq n, m\leq 10^3$) — the number of flowers and visitors respectively.

Each of the next $m$ lines contains two integers $l_i$ and $r_i$ ($1\leq l_i\leq r_i\leq n$), meaning that $i$-th visitor will visit all flowers from $l_i$ to $r_i$ inclusive.

-----Output-----

Print the string of $n$ characters. The $i$-th symbol should be «0» if you want to put a rose in the $i$-th position, otherwise «1» if you want to put a lily.

If there are multiple answers, print any.

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

Output
01100
Input
6 3
5 6
1 4
4 6

Output
110010

-----Note-----

In the first example, Sonya can put roses in the first, fourth, and fifth positions, and lilies in the second and third positions;

  in the segment $[1\ldots3]$, there are one rose and two lilies, so the beauty is equal to $1\cdot 2=2$;  in the segment $[2\ldots4]$, there are one rose and two lilies, so the beauty is equal to $1\cdot 2=2$;  in the segment $[2\ldots5]$, there are two roses and two lilies, so the beauty is equal to $2\cdot 2=4$.

The total beauty is equal to $2+2+4=8$.

In the second example, Sonya can put roses in the third, fourth, and sixth positions, and lilies in the first, second, and fifth positions;

  in the segment $[5\ldots6]$, there are one rose and one lily, so the beauty is equal to $1\cdot 1=1$;  in the segment $[1\ldots4]$, there are two roses and two lilies, so the beauty is equal to $2\cdot 2=4$;  in the segment $[4\ldots6]$, there are two roses and one lily, so the beauty is equal to $2\cdot 1=2$.

The total beauty is equal to $1+4+2=7$.


Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).

Valera wants to place exactly k tubes on his rectangle table. A tube is such sequence of table cells (x_1, y_1), (x_2, y_2), ..., (x_{r}, y_{r}), that:   r ≥ 2;  for any integer i (1 ≤ i ≤ r - 1) the following equation |x_{i} - x_{i} + 1| + |y_{i} - y_{i} + 1| = 1 holds;  each table cell, which belongs to the tube, must occur exactly once in the sequence.

Valera thinks that the tubes are arranged in a fancy manner if the following conditions are fulfilled:   no pair of tubes has common cells;  each cell of the table belongs to some tube.

Help Valera to arrange k tubes on his rectangle table in a fancy manner.

-----Input-----

The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.

-----Output-----

Print k lines. In the i-th line print the description of the i-th tube: first print integer r_{i} (the number of tube cells), then print 2r_{i} integers x_{i}1, y_{i}1, x_{i}2, y_{i}2, ..., x_{ir}_{i}, y_{ir}_{i} (the sequence of table cells).

If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution exists.

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

Output
3 1 1 1 2 1 3
3 2 1 2 2 2 3
3 3 1 3 2 3 3

Input
2 3 1

Output
6 1 1 1 2 1 3 2 3 2 2 2 1

-----Note-----

Picture for the first sample:  [Image]

Picture for the second sample:  [Image]


You are given a positive integer $D$. Let's build the following graph from it:   each vertex is a divisor of $D$ (not necessarily prime, $1$ and $D$ itself are also included);  two vertices $x$ and $y$ ($x > y$) have an undirected edge between them if $x$ is divisible by $y$ and $\frac x y$ is a prime;  the weight of an edge is the number of divisors of $x$ that are not divisors of $y$.

For example, here is the graph for $D=12$:  [Image]

Edge $(4,12)$ has weight $3$ because $12$ has divisors $[1,2,3,4,6,12]$ and $4$ has divisors $[1,2,4]$. Thus, there are $3$ divisors of $12$ that are not divisors of $4$ — $[3,6,12]$.

There is no edge between $3$ and $2$ because $3$ is not divisible by $2$. There is no edge between $12$ and $3$ because $\frac{12}{3}=4$ is not a prime.

Let the length of the path between some vertices $v$ and $u$ in the graph be the total weight of edges on it. For example, path $[(1, 2), (2, 6), (6, 12), (12, 4), (4, 2), (2, 6)]$ has length $1+2+2+3+1+2=11$. The empty path has length $0$.

So the shortest path between two vertices $v$ and $u$ is the path that has the minimal possible length.

Two paths $a$ and $b$ are different if there is either a different number of edges in them or there is a position $i$ such that $a_i$ and $b_i$ are different edges.

You are given $q$ queries of the following form:   $v$ $u$ — calculate the number of the shortest paths between vertices $v$ and $u$.

The answer for each query might be large so print it modulo $998244353$.

-----Input-----

The first line contains a single integer $D$ ($1 \le D \le 10^{15}$) — the number the graph is built from.

The second line contains a single integer $q$ ($1 \le q \le 3 \cdot 10^5$) — the number of queries.

Each of the next $q$ lines contains two integers $v$ and $u$ ($1 \le v, u \le D$). It is guaranteed that $D$ is divisible by both $v$ and $u$ (both $v$ and $u$ are divisors of $D$).

-----Output-----

Print $q$ integers — for each query output the number of the shortest paths between the two given vertices modulo $998244353$.

-----Examples-----
Input
12
3
4 4
12 1
3 4

Output
1
3
1

Input
1
1
1 1

Output
1

Input
288807105787200
4
46 482955026400
12556830686400 897
414 12556830686400
4443186242880 325

Output
547558588
277147129
457421435
702277623

-----Note-----

In the first example:   The first query is only the empty path — length $0$;  The second query are paths $[(12, 4), (4, 2), (2, 1)]$ (length $3+1+1=5$), $[(12, 6), (6, 2), (2, 1)]$ (length $2+2+1=5$) and $[(12, 6), (6, 3), (3, 1)]$ (length $2+2+1=5$).  The third query is only the path $[(3, 1), (1, 2), (2, 4)]$ (length $1+1+1=3$).


General Payne has a battalion of n soldiers. The soldiers' beauty contest is coming up, it will last for k days. Payne decided that his battalion will participate in the pageant. Now he has choose the participants.

All soldiers in the battalion have different beauty that is represented by a positive integer. The value a_{i} represents the beauty of the i-th soldier.

On each of k days Generals has to send a detachment of soldiers to the pageant. The beauty of the detachment is the sum of the beauties of the soldiers, who are part of this detachment. Payne wants to surprise the jury of the beauty pageant, so each of k days the beauty of the sent detachment should be unique. In other words, all k beauties of the sent detachments must be distinct numbers.

Help Payne choose k detachments of different beauties for the pageant. Please note that Payne cannot just forget to send soldiers on one day, that is, the detachment of soldiers he sends to the pageant should never be empty.

-----Input-----

The first line contains two integers n, k (1 ≤ n ≤ 50; 1 ≤ k ≤  $\frac{n(n + 1)}{2}$) — the number of soldiers and the number of days in the pageant, correspondingly. The second line contains space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^7) — the beauties of the battalion soldiers.

It is guaranteed that Payne's battalion doesn't have two soldiers with the same beauty.

-----Output-----

Print k lines: in the i-th line print the description of the detachment that will participate in the pageant on the i-th day. The description consists of integer c_{i} (1 ≤ c_{i} ≤ n) — the number of soldiers in the detachment on the i-th day of the pageant and c_{i} distinct integers p_{1, }i, p_{2, }i, ..., p_{c}_{i}, i — the beauties of the soldiers in the detachment on the i-th day of the pageant. The beauties of the soldiers are allowed to print in any order.

Separate numbers on the lines by spaces. It is guaranteed that there is the solution that meets the problem conditions. If there are multiple solutions, print any of them.

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

Output
1 1
1 2
2 3 2

Input
2 1
7 12

Output
1 12


You are given an integer $n$ and an integer $k$.

In one step you can do one of the following moves:   decrease $n$ by $1$;  divide $n$ by $k$ if $n$ is divisible by $k$.

For example, if $n = 27$ and $k = 3$ you can do the following steps: $27 \rightarrow 26 \rightarrow 25 \rightarrow 24 \rightarrow 8 \rightarrow 7 \rightarrow 6 \rightarrow 2 \rightarrow 1 \rightarrow 0$.

You are asked to calculate the minimum number of steps to reach $0$ from $n$.

-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of queries.

The only line of each query contains two integers $n$ and $k$ ($1 \le n \le 10^{18}$, $2 \le k \le 10^{18}$).

-----Output-----

For each query print the minimum number of steps to reach $0$ from $n$ in single line.

-----Example-----
Input
2
59 3
1000000000000000000 10

Output
8
19

-----Note-----

Steps for the first test case are: $59 \rightarrow 58 \rightarrow 57 \rightarrow 19 \rightarrow 18 \rightarrow 6 \rightarrow 2 \rightarrow 1 \rightarrow 0$.

In the second test case you have to divide $n$ by $k$ $18$ times and then decrease $n$ by $1$.


There are $n$ emotes in very popular digital collectible card game (the game is pretty famous so we won't say its name). The $i$-th emote increases the opponent's happiness by $a_i$ units (we all know that emotes in this game are used to make opponents happy).

You have time to use some emotes only $m$ times. You are allowed to use any emotion once, more than once, or not use it at all. The only restriction is that you cannot use the same emote more than $k$ times in a row (otherwise the opponent will think that you're trolling him).

Note that two emotes $i$ and $j$ ($i \ne j$) such that $a_i = a_j$ are considered different.

You have to make your opponent as happy as possible. Find the maximum possible opponent's happiness.

-----Input-----

The first line of the input contains three integers $n, m$ and $k$ ($2 \le n \le 2 \cdot 10^5$, $1 \le k \le m \le 2 \cdot 10^9$) — the number of emotes, the number of times you can use emotes and the maximum number of times you may use the same emote in a row.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is value of the happiness of the $i$-th emote.

-----Output-----

Print one integer — the maximum opponent's happiness if you use emotes in a way satisfying the problem statement.

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

Output
54

Input
3 1000000000 1
1000000000 987654321 1000000000

Output
1000000000000000000

-----Note-----

In the first example you may use emotes in the following sequence: $4, 4, 5, 4, 4, 5, 4, 4, 5$.


You a captain of a ship. Initially you are standing in a point $(x_1, y_1)$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $(x_2, y_2)$.

You know the weather forecast — the string $s$ of length $n$, consisting only of letters U, D, L and R. The letter corresponds to a direction of wind. Moreover, the forecast is periodic, e.g. the first day wind blows to the side $s_1$, the second day — $s_2$, the $n$-th day — $s_n$ and $(n+1)$-th day — $s_1$ again and so on.

Ship coordinates change the following way:  if wind blows the direction U, then the ship moves from $(x, y)$ to $(x, y + 1)$;  if wind blows the direction D, then the ship moves from $(x, y)$ to $(x, y - 1)$;  if wind blows the direction L, then the ship moves from $(x, y)$ to $(x - 1, y)$;  if wind blows the direction R, then the ship moves from $(x, y)$ to $(x + 1, y)$.

The ship can also either go one of the four directions or stay in place each day. If it goes then it's exactly 1 unit of distance. Transpositions of the ship and the wind add up. If the ship stays in place, then only the direction of wind counts. For example, if wind blows the direction U and the ship moves the direction L, then from point $(x, y)$ it will move to the point $(x - 1, y + 1)$, and if it goes the direction U, then it will move to the point $(x, y + 2)$.

You task is to determine the minimal number of days required for the ship to reach the point $(x_2, y_2)$.

-----Input-----

The first line contains two integers $x_1, y_1$ ($0 \le x_1, y_1 \le 10^9$) — the initial coordinates of the ship.

The second line contains two integers $x_2, y_2$ ($0 \le x_2, y_2 \le 10^9$) — the coordinates of the destination point.

It is guaranteed that the initial coordinates and destination point coordinates are different.

The third line contains a single integer $n$ ($1 \le n \le 10^5$) — the length of the string $s$.

The fourth line contains the string $s$ itself, consisting only of letters U, D, L and R.

-----Output-----

The only line should contain the minimal number of days required for the ship to reach the point $(x_2, y_2)$.

If it's impossible then print "-1".

-----Examples-----
Input
0 0
4 6
3
UUU

Output
5

Input
0 3
0 0
3
UDD

Output
3

Input
0 0
0 1
1
L

Output
-1

-----Note-----

In the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $(0, 0)$ $\rightarrow$ $(1, 1)$ $\rightarrow$ $(2, 2)$ $\rightarrow$ $(3, 3)$ $\rightarrow$ $(4, 4)$ $\rightarrow$ $(4, 6)$.

In the second example the ship should perform the following sequence of moves: "DD" (the third day it should stay in place). Then its coordinates will change accordingly: $(0, 3)$ $\rightarrow$ $(0, 3)$ $\rightarrow$ $(0, 1)$ $\rightarrow$ $(0, 0)$.

In the third example the ship can never reach the point $(0, 1)$.


Now Serval is a junior high school student in Japari Middle School, and he is still thrilled on math as before.

As a talented boy in mathematics, he likes to play with numbers. This time, he wants to play with numbers on a rooted tree.

A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. A parent of a node $v$ is the last different from $v$ vertex on the path from the root to the vertex $v$. Children of vertex $v$ are all nodes for which $v$ is the parent. A vertex is a leaf if it has no children.

The rooted tree Serval owns has $n$ nodes, node $1$ is the root. Serval will write some numbers into all nodes of the tree. However, there are some restrictions. Each of the nodes except leaves has an operation $\max$ or $\min$ written in it, indicating that the number in this node should be equal to the maximum or minimum of all the numbers in its sons, respectively.

Assume that there are $k$ leaves in the tree. Serval wants to put integers $1, 2, \ldots, k$ to the $k$ leaves (each number should be used exactly once). He loves large numbers, so he wants to maximize the number in the root. As his best friend, can you help him?

-----Input-----

The first line contains an integer $n$ ($2 \leq n \leq 3\cdot 10^5$), the size of the tree.

The second line contains $n$ integers, the $i$-th of them represents the operation in the node $i$. $0$ represents $\min$ and $1$ represents $\max$. If the node is a leaf, there is still a number of $0$ or $1$, but you can ignore it.

The third line contains $n-1$ integers $f_2, f_3, \ldots, f_n$ ($1 \leq f_i \leq i-1$), where $f_i$ represents the parent of the node $i$.

-----Output-----

Output one integer — the maximum possible number in the root of the tree.

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

Output
1

Input
5
1 0 1 0 1
1 1 1 1

Output
4

Input
8
1 0 0 1 0 1 1 0
1 1 2 2 3 3 3

Output
4

Input
9
1 1 0 0 1 0 1 0 1
1 1 2 2 3 3 4 4

Output
5

-----Note-----

Pictures below explain the examples. The numbers written in the middle of the nodes are their indices, and the numbers written on the top are the numbers written in the nodes.

In the first example, no matter how you arrange the numbers, the answer is $1$. [Image]

In the second example, no matter how you arrange the numbers, the answer is $4$. [Image]

In the third example, one of the best solution to achieve $4$ is to arrange $4$ and $5$ to nodes $4$ and $5$. [Image]

In the fourth example, the best solution is to arrange $5$ to node $5$. [Image]


You're given a tree with $n$ vertices.

Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.

-----Input-----

The first line contains an integer $n$ ($1 \le n \le 10^5$) denoting the size of the tree.

The next $n - 1$ lines contain two integers $u$, $v$ ($1 \le u, v \le n$) each, describing the vertices connected by the $i$-th edge.

It's guaranteed that the given edges form a tree.

-----Output-----

Output a single integer $k$ — the maximum number of edges that can be removed to leave all connected components with even size, or $-1$ if it is impossible to remove edges in order to satisfy this property.

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

Output
1
Input
3
1 2
1 3

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

Output
4
Input
2
1 2

Output
0

-----Note-----

In the first example you can remove the edge between vertices $1$ and $4$. The graph after that will have two connected components with two vertices in each.

In the second example you can't remove edges in such a way that all components have even number of vertices, so the answer is $-1$.


Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connects some pair of settlements and is bidirectional. Moreover, it is possible to reach any settlement from any other one by traversing one or several paths.

The distance between two settlements is the minimum number of paths that have to be crossed to get from one settlement to the other one. Manao knows that the Book of Evil has got a damage range d. This means that if the Book of Evil is located in some settlement, its damage (for example, emergence of ghosts and werewolves) affects other settlements at distance d or less from the settlement where the Book resides.

Manao has heard of m settlements affected by the Book of Evil. Their numbers are p_1, p_2, ..., p_{m}. Note that the Book may be affecting other settlements as well, but this has not been detected yet. Manao wants to determine which settlements may contain the Book. Help him with this difficult task.

-----Input-----

The first line contains three space-separated integers n, m and d (1 ≤ m ≤ n ≤ 100000; 0 ≤ d ≤ n - 1). The second line contains m distinct space-separated integers p_1, p_2, ..., p_{m} (1 ≤ p_{i} ≤ n). Then n - 1 lines follow, each line describes a path made in the area. A path is described by a pair of space-separated integers a_{i} and b_{i} representing the ends of this path.

-----Output-----

Print a single number — the number of settlements that may contain the Book of Evil. It is possible that Manao received some controversial information and there is no settlement that may contain the Book. In such case, print 0.

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

Output
3

-----Note-----

Sample 1. The damage range of the Book of Evil equals 3 and its effects have been noticed in settlements 1 and 2. Thus, it can be in settlements 3, 4 or 5.

 [Image]


Xenia the beginner programmer has a sequence a, consisting of 2^{n} non-negative integers: a_1, a_2, ..., a_2^{n}. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a.

Namely, it takes several iterations to calculate value v. At the first iteration, Xenia writes a new sequence a_1 or a_2, a_3 or a_4, ..., a_2^{n} - 1 or a_2^{n}, consisting of 2^{n} - 1 elements. In other words, she writes down the bit-wise OR of adjacent elements of sequence a. At the second iteration, Xenia writes the bitwise exclusive OR of adjacent elements of the sequence obtained after the first iteration. At the third iteration Xenia writes the bitwise OR of the adjacent elements of the sequence obtained after the second iteration. And so on; the operations of bitwise exclusive OR and bitwise OR alternate. In the end, she obtains a sequence consisting of one element, and that element is v.

Let's consider an example. Suppose that sequence a = (1, 2, 3, 4). Then let's write down all the transformations (1, 2, 3, 4)  →  (1 or 2 = 3, 3 or 4 = 7)  →  (3 xor 7 = 4). The result is v = 4.

You are given Xenia's initial sequence. But to calculate value v for a given sequence would be too easy, so you are given additional m queries. Each query is a pair of integers p, b. Query p, b means that you need to perform the assignment a_{p} = b. After each query, you need to print the new value v for the new sequence a.

-----Input-----

The first line contains two integers n and m (1 ≤ n ≤ 17, 1 ≤ m ≤ 10^5). The next line contains 2^{n} integers a_1, a_2, ..., a_2^{n} (0 ≤ a_{i} < 2^30). Each of the next m lines contains queries. The i-th line contains integers p_{i}, b_{i} (1 ≤ p_{i} ≤ 2^{n}, 0 ≤ b_{i} < 2^30) — the i-th query.

-----Output-----

Print m integers — the i-th integer denotes value v for sequence a after the i-th query.

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

Output
1
3
3
3

-----Note-----

For more information on the bit operations, you can follow this link: http://en.wikipedia.org/wiki/Bitwise_operation


You are given a simple weighted connected undirected graph, consisting of $n$ vertices and $m$ edges.

A path in the graph of length $k$ is a sequence of $k+1$ vertices $v_1, v_2, \dots, v_{k+1}$ such that for each $i$ $(1 \le i \le k)$ the edge $(v_i, v_{i+1})$ is present in the graph. A path from some vertex $v$ also has vertex $v_1=v$. Note that edges and vertices are allowed to be included in the path multiple times.

The weight of the path is the total weight of edges in it.

For each $i$ from $1$ to $q$ consider a path from vertex $1$ of length $i$ of the maximum weight. What is the sum of weights of these $q$ paths?

Answer can be quite large, so print it modulo $10^9+7$.

-----Input-----

The first line contains a three integers $n$, $m$, $q$ ($2 \le n \le 2000$; $n - 1 \le m \le 2000$; $m \le q \le 10^9$) — the number of vertices in the graph, the number of edges in the graph and the number of lengths that should be included in the answer.

Each of the next $m$ lines contains a description of an edge: three integers $v$, $u$, $w$ ($1 \le v, u \le n$; $1 \le w \le 10^6$) — two vertices $v$ and $u$ are connected by an undirected edge with weight $w$. The graph contains no loops and no multiple edges. It is guaranteed that the given edges form a connected graph.

-----Output-----

Print a single integer — the sum of the weights of the paths from vertex $1$ of maximum weights of lengths $1, 2, \dots, q$ modulo $10^9+7$.

-----Examples-----
Input
7 8 25
1 2 1
2 3 10
3 4 2
1 5 2
5 6 7
6 4 15
5 3 1
1 7 3

Output
4361

Input
2 1 5
1 2 4

Output
60

Input
15 15 23
13 10 12
11 14 12
2 15 5
4 10 8
10 2 4
10 7 5
3 10 1
5 6 11
1 13 8
9 15 4
4 2 9
11 15 1
11 12 14
10 8 12
3 6 11

Output
3250

Input
5 10 10000000
2 4 798
1 5 824
5 2 558
4 1 288
3 4 1890
3 1 134
2 3 1485
4 5 284
3 5 1025
1 2 649

Output
768500592

-----Note-----

Here is the graph for the first example: [Image]

Some maximum weight paths are:   length $1$: edges $(1, 7)$ — weight $3$;  length $2$: edges $(1, 2), (2, 3)$ — weight $1+10=11$;  length $3$: edges $(1, 5), (5, 6), (6, 4)$ — weight $2+7+15=24$;  length $4$: edges $(1, 5), (5, 6), (6, 4), (6, 4)$ — weight $2+7+15+15=39$;  $\dots$

So the answer is the sum of $25$ terms: $3+11+24+39+\dots$

In the second example the maximum weight paths have weights $4$, $8$, $12$, $16$ and $20$.


Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.

Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequence of consecutive characters in a string) in a given text makes our hero especially joyful. Recently he felt an enormous fit of energy while reading a certain text. So Volodya decided to count all powerful substrings in this text and brag about it all day long. Help him in this difficult task. Two substrings are considered different if they appear at the different positions in the text.

For simplicity, let us assume that Volodya's text can be represented as a single string.

-----Input-----

Input contains a single non-empty string consisting of the lowercase Latin alphabet letters. Length of this string will not be greater than 10^6 characters.

-----Output-----

Print exactly one number — the number of powerful substrings of the given string.

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

-----Examples-----
Input
heavymetalisheavymetal

Output
3
Input
heavymetalismetal

Output
2
Input
trueheavymetalissotruewellitisalsosoheavythatyoucanalmostfeeltheweightofmetalonyou

Output
3

-----Note-----

In the first sample the string "heavymetalisheavymetal" contains powerful substring "heavymetal" twice, also the whole string "heavymetalisheavymetal" is certainly powerful.

In the second sample the string "heavymetalismetal" contains two powerful substrings: "heavymetal" and "heavymetalismetal".


During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesting is that these years are in the range $(1, 10^9)$! Therefore, the planet was named Longlifer.

In order to learn more about Longlifer's previous population, scientists need to determine the year with maximum number of individuals that were alive, as well as the number of alive individuals in that year. Your task is to help scientists solve this problem!

-----Input-----

The first line contains an integer $n$ ($1 \le n \le 10^5$) — the number of people.

Each of the following $n$ lines contain two integers $b$ and $d$ ($1 \le b \lt d \le 10^9$) representing birth and death year (respectively) of each individual.

-----Output-----

Print two integer numbers separated by blank character, $y$  — the year with a maximum number of people alive and $k$  — the number of people alive in year $y$.

In the case of multiple possible solutions, print the solution with minimum year.

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

Output
2 2

Input
4
3 4
4 5
4 6
8 10

Output
4 2

-----Note-----

You can assume that an individual living from $b$ to $d$ has been born at the beginning of $b$ and died at the beginning of $d$, and therefore living for $d$ - $b$ years.


Mahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same length such that:

  b is lexicographically greater than or equal to a.  b_{i} ≥ 2.  b is pairwise coprime: for every 1 ≤ i < j ≤ n, b_{i} and b_{j} are coprime, i. e. GCD(b_{i}, b_{j}) = 1, where GCD(w, z) is the greatest common divisor of w and z.

Ehab wants to choose a special array so he wants the lexicographically minimal array between all the variants. Can you find it?

An array x is lexicographically greater than an array y if there exists an index i such than x_{i} > y_{i} and x_{j} = y_{j} for all 1 ≤ j < i. An array x is equal to an array y if x_{i} = y_{i} for all 1 ≤ i ≤ n.

-----Input-----

The first line contains an integer n (1 ≤ n ≤ 10^5), the number of elements in a and b.

The second line contains n integers a_1, a_2, ..., a_{n} (2 ≤ a_{i} ≤ 10^5), the elements of a.

-----Output-----

Output n space-separated integers, the i-th of them representing b_{i}.

-----Examples-----
Input
5
2 3 5 4 13

Output
2 3 5 7 11
Input
3
10 3 7

Output
10 3 7

-----Note-----

Note that in the second sample, the array is already pairwise coprime so we printed it.


Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag with k candies.

Help him give n bags of candies to each brother so that all brothers got the same number of candies.

-----Input-----

The single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.

-----Output-----

Let's assume that Gerald indexes his brothers with numbers from 1 to n. You need to print n lines, on the i-th line print n integers — the numbers of candies in the bags for the i-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to n^2. You can print the numbers in the lines in any order.

It is guaranteed that the solution exists at the given limits.

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

Output
1 4
2 3

-----Note-----

The sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother.


You have $n$ sticks of the given lengths.

Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose such sticks.

Let $S$ be the area of the rectangle and $P$ be the perimeter of the rectangle.

The chosen rectangle should have the value $\frac{P^2}{S}$ minimal possible. The value is taken without any rounding.

If there are multiple answers, print any of them.

Each testcase contains several lists of sticks, for each of them you are required to solve the problem separately.

-----Input-----

The first line contains a single integer $T$ ($T \ge 1$) — the number of lists of sticks in the testcase.

Then $2T$ lines follow — lines $(2i - 1)$ and $2i$ of them describe the $i$-th list. The first line of the pair contains a single integer $n$ ($4 \le n \le 10^6$) — the number of sticks in the $i$-th list. The second line of the pair contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_j \le 10^4$) — lengths of the sticks in the $i$-th list.

It is guaranteed that for each list there exists a way to choose four sticks so that they form a rectangle.

The total number of sticks in all $T$ lists doesn't exceed $10^6$ in each testcase.

-----Output-----

Print $T$ lines. The $i$-th line should contain the answer to the $i$-th list of the input. That is the lengths of the four sticks you choose from the $i$-th list, so that they form a rectangle and the value $\frac{P^2}{S}$ of this rectangle is minimal possible. You can print these four lengths in arbitrary order.

If there are multiple answers, print any of them.

-----Example-----
Input
3
4
7 2 2 7
8
2 8 1 4 8 2 1 5
5
5 5 5 5 5

Output
2 7 7 2
2 2 1 1
5 5 5 5

-----Note-----

There is only one way to choose four sticks in the first list, they form a rectangle with sides $2$ and $7$, its area is $2 \cdot 7 = 14$, perimeter is $2(2 + 7) = 18$. $\frac{18^2}{14} \approx 23.143$.

The second list contains subsets of four sticks that can form rectangles with sides $(1, 2)$, $(2, 8)$ and $(1, 8)$. Their values are $\frac{6^2}{2} = 18$, $\frac{20^2}{16} = 25$ and $\frac{18^2}{8} = 40.5$, respectively. The minimal one of them is the rectangle $(1, 2)$.

You can choose any four of the $5$ given sticks from the third list, they will form a square with side $5$, which is still a rectangle with sides $(5, 5)$.


You are given an undirected unweighted tree consisting of $n$ vertices.

An undirected tree is a connected undirected graph with $n - 1$ edges.

Your task is to choose two pairs of vertices of this tree (all the chosen vertices should be distinct) $(x_1, y_1)$ and $(x_2, y_2)$ in such a way that neither $x_1$ nor $y_1$ belong to the simple path from $x_2$ to $y_2$ and vice versa (neither $x_2$ nor $y_2$ should not belong to the simple path from $x_1$ to $y_1$).

It is guaranteed that it is possible to choose such pairs for the given tree.

Among all possible ways to choose such pairs you have to choose one with the maximum number of common vertices between paths from $x_1$ to $y_1$ and from $x_2$ to $y_2$. And among all such pairs you have to choose one with the maximum total length of these two paths.

It is guaranteed that the answer with at least two common vertices exists for the given tree.

The length of the path is the number of edges in it.

The simple path is the path that visits each vertex at most once.

-----Input-----

The first line contains an integer $n$ — the number of vertices in the tree ($6 \le n \le 2 \cdot 10^5$).

Each of the next $n - 1$ lines describes the edges of the tree.

Edge $i$ is denoted by two integers $u_i$ and $v_i$, the labels of vertices it connects ($1 \le u_i, v_i \le n$, $u_i \ne v_i$).

It is guaranteed that the given edges form a tree.

It is guaranteed that the answer with at least two common vertices exists for the given tree.

-----Output-----

Print any two pairs of vertices satisfying the conditions described in the problem statement.

It is guaranteed that it is possible to choose such pairs for the given tree.

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

Output
3 6
7 5

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

Output
2 9
6 8

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

Output
10 6
4 5

Input
11
1 2
2 3
3 4
1 5
1 6
6 7
5 8
5 9
4 10
4 11

Output
9 11
8 10

-----Note-----

The picture corresponding to the first example: [Image]

The intersection of two paths is $2$ (vertices $1$ and $4$) and the total length is $4 + 3 = 7$.

The picture corresponding to the second example: [Image]

The intersection of two paths is $2$ (vertices $3$ and $4$) and the total length is $5 + 3 = 8$.

The picture corresponding to the third example: $88^{\circ}$

The intersection of two paths is $3$ (vertices $2$, $7$ and $8$) and the total length is $5 + 5 = 10$.

The picture corresponding to the fourth example: $\$ 8$

The intersection of two paths is $5$ (vertices $1$, $2$, $3$, $4$ and $5$) and the total length is $6 + 6 = 12$.


This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.

After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.

Ujan has two distinct strings $s$ and $t$ of length $n$ consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions $i$ and $j$ ($1 \le i,j \le n$, the values $i$ and $j$ can be equal or different), and swaps the characters $s_i$ and $t_j$. Can he succeed?

Note that he has to perform this operation exactly once. He has to perform this operation.

-----Input-----

The first line contains a single integer $k$ ($1 \leq k \leq 10$), the number of test cases.

For each of the test cases, the first line contains a single integer $n$ ($2 \leq n \leq 10^4$), the length of the strings $s$ and $t$.

Each of the next two lines contains the strings $s$ and $t$, each having length exactly $n$. The strings consist only of lowercase English letters. It is guaranteed that strings are different.

-----Output-----

For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.

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

-----Example-----
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca

Output
Yes
No
No
No

-----Note-----

In the first test case, Ujan can swap characters $s_1$ and $t_4$, obtaining the word "house".

In the second test case, it is not possible to make the strings equal using exactly one swap of $s_i$ and $t_j$.


We have a point $A$ with coordinate $x = n$ on $OX$-axis. We'd like to find an integer point $B$ (also on $OX$-axis), such that the absolute difference between the distance from $O$ to $B$ and the distance from $A$ to $B$ is equal to $k$. [Image] The description of the first test case.

Since sometimes it's impossible to find such point $B$, we can, in one step, increase or decrease the coordinate of $A$ by $1$. What is the minimum number of steps we should do to make such point $B$ exist?

-----Input-----

The first line contains one integer $t$ ($1 \le t \le 6000$) — the number of test cases.

The only line of each test case contains two integers $n$ and $k$ ($0 \le n, k \le 10^6$) — the initial position of point $A$ and desirable absolute difference.

-----Output-----

For each test case, print the minimum number of steps to make point $B$ exist.

-----Example-----
Input
6
4 0
5 8
0 1000000
0 0
1 0
1000000 1000000

Output
0
3
1000000
0
1
0

-----Note-----

In the first test case (picture above), if we set the coordinate of $B$ as $2$ then the absolute difference will be equal to $|(2 - 0) - (4 - 2)| = 0$ and we don't have to move $A$. So the answer is $0$.

In the second test case, we can increase the coordinate of $A$ by $3$ and set the coordinate of $B$ as $0$ or $8$. The absolute difference will be equal to $|8 - 0| = 8$, so the answer is $3$. [Image]


A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.

The fare is constructed in the following manner. There are three types of tickets:   a ticket for one trip costs 20 byteland rubles,  a ticket for 90 minutes costs 50 byteland rubles,  a ticket for one day (1440 minutes) costs 120 byteland rubles.

Note that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.

To simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.

You have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.

-----Input-----

The first line of input contains integer number n (1 ≤ n ≤ 10^5) — the number of trips made by passenger.

Each of the following n lines contains the time of trip t_{i} (0 ≤ t_{i} ≤ 10^9), measured in minutes from the time of starting the system. All t_{i} are different, given in ascending order, i. e. t_{i} + 1 > t_{i} holds for all 1 ≤ i < n.

-----Output-----

Output n integers. For each trip, print the sum the passenger is charged after it.

-----Examples-----
Input
3
10
20
30

Output
20
20
10

Input
10
13
45
46
60
103
115
126
150
256
516

Output
20
20
10
0
20
0
0
20
20
10

-----Note-----

In the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.


There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n > 1. No bank is a neighbour of itself.

Vasya has an account in each bank. Its balance may be negative, meaning Vasya owes some money to this bank.

There is only one type of operations available: transfer some amount of money from any bank to account in any neighbouring bank. There are no restrictions on the size of the sum being transferred or balance requirements to perform this operation.

Vasya doesn't like to deal with large numbers, so he asks you to determine the minimum number of operations required to change the balance of each bank account to zero. It's guaranteed, that this is possible to achieve, that is, the total balance of Vasya in all banks is equal to zero.

-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of banks.

The second line contains n integers a_{i} ( - 10^9 ≤ a_{i} ≤ 10^9), the i-th of them is equal to the initial balance of the account in the i-th bank. It's guaranteed that the sum of all a_{i} is equal to 0.

-----Output-----

Print the minimum number of operations required to change balance in each bank to zero.

-----Examples-----
Input
3
5 0 -5

Output
1

Input
4
-1 0 1 0

Output
2

Input
4
1 2 3 -6

Output
3

-----Note-----

In the first sample, Vasya may transfer 5 from the first bank to the third.

In the second sample, Vasya may first transfer 1 from the third bank to the second, and then 1 from the second to the first.

In the third sample, the following sequence provides the optimal answer:   transfer 1 from the first bank to the second bank;  transfer 3 from the second bank to the third;  transfer 6 from the third bank to the fourth.


Kuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen $n$ distinct positive integers and put all of them in a set $S$. Now he defines a magical permutation to be: A permutation of integers from $0$ to $2^x - 1$, where $x$ is a non-negative integer.  The bitwise xor of any two consecutive elements in the permutation is an element in $S$.

Since Kuro is really excited about magical permutations, he wants to create the longest magical permutation possible. In other words, he wants to find the largest non-negative integer $x$ such that there is a magical permutation of integers from $0$ to $2^x - 1$. Since he is a newbie in the subject, he wants you to help him find this value of $x$ and also the magical permutation for that $x$.

-----Input-----

The first line contains the integer $n$ ($1 \leq n \leq 2 \cdot 10^5$) — the number of elements in the set $S$.

The next line contains $n$ distinct integers $S_1, S_2, \ldots, S_n$ ($1 \leq S_i \leq 2 \cdot 10^5$) — the elements in the set $S$.

-----Output-----

In the first line print the largest non-negative integer $x$, such that there is a magical permutation of integers from $0$ to $2^x - 1$.

Then print $2^x$ integers describing a magical permutation of integers from $0$ to $2^x - 1$. If there are multiple such magical permutations, print any of them.

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

Output
2
0 1 3 2
Input
2
2 3

Output
2
0 2 1 3
Input
4
1 2 3 4

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

Output
0
0
Input
1
20

Output
0
0
Input
1
1

Output
1
0 1

-----Note-----

In the first example, $0, 1, 3, 2$ is a magical permutation since: $0 \oplus 1 = 1 \in S$  $1 \oplus 3 = 2 \in S$  $3 \oplus 2 = 1 \in S$

Where $\oplus$ denotes bitwise xor operation.


Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n × n matrix with a diamond inscribed into it.

You are given an odd integer n. You need to draw a crystal of size n. The diamond cells of the matrix should be represented by character "D". All other cells of the matrix should be represented by character "*". Look at the examples to understand what you need to draw.

-----Input-----

The only line contains an integer n (3 ≤ n ≤ 101; n is odd).

-----Output-----

Output a crystal of size n.

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

Output
*D*
DDD
*D*

Input
5

Output
**D**
*DDD*
DDDDD
*DDD*
**D**

Input
7

Output
***D***
**DDD**
*DDDDD*
DDDDDDD
*DDDDD*
**DDD**
***D***


Mishka got a six-faced dice. It has integer numbers from $2$ to $7$ written on its faces (all numbers on faces are different, so this is an almost usual dice).

Mishka wants to get exactly $x$ points by rolling his dice. The number of points is just a sum of numbers written at the topmost face of the dice for all the rolls Mishka makes.

Mishka doesn't really care about the number of rolls, so he just wants to know any number of rolls he can make to be able to get exactly $x$ points for them. Mishka is very lucky, so if the probability to get $x$ points with chosen number of rolls is non-zero, he will be able to roll the dice in such a way. Your task is to print this number. It is guaranteed that at least one answer exists.

Mishka is also very curious about different number of points to score so you have to answer $t$ independent queries.

-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 100$) — the number of queries.

Each of the next $t$ lines contains one integer each. The $i$-th line contains one integer $x_i$ ($2 \le x_i \le 100$) — the number of points Mishka wants to get.

-----Output-----

Print $t$ lines. In the $i$-th line print the answer to the $i$-th query (i.e. any number of rolls Mishka can make to be able to get exactly $x_i$ points for them). It is guaranteed that at least one answer exists.

-----Example-----
Input
4
2
13
37
100

Output
1
3
8
27

-----Note-----

In the first query Mishka can roll a dice once and get $2$ points.

In the second query Mishka can roll a dice $3$ times and get points $5$, $5$ and $3$ (for example).

In the third query Mishka can roll a dice $8$ times and get $5$ points $7$ times and $2$ points with the remaining roll.

In the fourth query Mishka can roll a dice $27$ times and get $2$ points $11$ times, $3$ points $6$ times and $6$ points $10$ times.


One of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $s$ towards a faraway galaxy. Recently they've received a response $t$ which they believe to be a response from aliens! The scientists now want to check if the signal $t$ is similar to $s$.

The original signal $s$ was a sequence of zeros and ones (everyone knows that binary code is the universe-wide language). The returned signal $t$, however, does not look as easy as $s$, but the scientists don't give up! They represented $t$ as a sequence of English letters and say that $t$ is similar to $s$ if you can replace all zeros in $s$ with some string $r_0$ and all ones in $s$ with some other string $r_1$ and obtain $t$. The strings $r_0$ and $r_1$ must be different and non-empty.

Please help Arkady's friend and find the number of possible replacements for zeros and ones (the number of pairs of strings $r_0$ and $r_1$) that transform $s$ to $t$.

-----Input-----

The first line contains a string $s$ ($2 \le |s| \le 10^5$) consisting of zeros and ones — the original signal.

The second line contains a string $t$ ($1 \le |t| \le 10^6$) consisting of lowercase English letters only — the received signal.

It is guaranteed, that the string $s$ contains at least one '0' and at least one '1'.

-----Output-----

Print a single integer — the number of pairs of strings $r_0$ and $r_1$ that transform $s$ to $t$.

In case there are no such pairs, print $0$.

-----Examples-----
Input
01
aaaaaa

Output
4

Input
001
kokokokotlin

Output
2

-----Note-----

In the first example, the possible pairs $(r_0, r_1)$ are as follows:  "a", "aaaaa"  "aa", "aaaa"  "aaaa", "aa"  "aaaaa", "a"

The pair "aaa", "aaa" is not allowed, since $r_0$ and $r_1$ must be different.

In the second example, the following pairs are possible:   "ko", "kokotlin"  "koko", "tlin"


Inna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much.

A song is a sequence of notes. Dima and Inna want to play each note at the same time. At that, they can play the i-th note at volume v (1 ≤ v ≤ a_{i}; v is an integer) both on the piano and the guitar. They should retain harmony, so the total volume with which the i-th note was played on the guitar and the piano must equal b_{i}. If Dima and Inna cannot play a note by the described rules, they skip it and Sereja's joy drops by 1. But if Inna and Dima play the i-th note at volumes x_{i} and y_{i} (x_{i} + y_{i} = b_{i}) correspondingly, Sereja's joy rises by x_{i}·y_{i}.

Sereja has just returned home from the university and his current joy is 0. Help Dima and Inna play the song so as to maximize Sereja's total joy after listening to the whole song!

-----Input-----

The first line of the input contains integer n (1 ≤ n ≤ 10^5) — the number of notes in the song. The second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6). The third line contains n integers b_{i} (1 ≤ b_{i} ≤ 10^6).

-----Output-----

In a single line print an integer — the maximum possible joy Sereja feels after he listens to a song.

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

Output
4

Input
1
2
5

Output
-1

-----Note-----

In the first sample, Dima and Inna play the first two notes at volume 1 (1 + 1 = 2, the condition holds), they should play the last note at volumes 1 and 2. Sereja's total joy equals: 1·1 + 1·1 + 1·2 = 4.

In the second sample, there is no such pair (x, y), that 1 ≤ x, y ≤ 2, x + y = 5, so Dima and Inna skip a note. Sereja's total joy equals -1.


Given is a string S consisting of digits from 1 through 9.
Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:
Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

-----Constraints-----
 - 1 ≤ |S| ≤ 200000
 - S is a string consisting of digits from 1 through 9.

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition.

-----Sample Input-----
1817181712114

-----Sample Output-----
3

Three pairs - (1,5), (5,9), and (9,13) - satisfy the condition.


Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t_{i}. The bigger this value is, the better the friendship is. No two friends have the same value t_{i}.

Spring is starting and the Winter sleep is over for bears. Limak has just woken up and logged in. All his friends still sleep and thus none of them is online. Some (maybe all) of them will appear online in the next hours, one at a time.

The system displays friends who are online. On the screen there is space to display at most k friends. If there are more than k friends online then the system displays only k best of them — those with biggest t_{i}.

Your task is to handle queries of two types:  "1 id" — Friend id becomes online. It's guaranteed that he wasn't online before.  "2 id" — Check whether friend id is displayed by the system. Print "YES" or "NO" in a separate line.

Are you able to help Limak and answer all queries of the second type?

-----Input-----

The first line contains three integers n, k and q (1 ≤ n, q ≤ 150 000, 1 ≤ k ≤ min(6, n)) — the number of friends, the maximum number of displayed online friends and the number of queries, respectively.

The second line contains n integers t_1, t_2, ..., t_{n} (1 ≤ t_{i} ≤ 10^9) where t_{i} describes how good is Limak's relation with the i-th friend.

The i-th of the following q lines contains two integers type_{i} and id_{i} (1 ≤ type_{i} ≤ 2, 1 ≤ id_{i} ≤ n) — the i-th query. If type_{i} = 1 then a friend id_{i} becomes online. If type_{i} = 2 then you should check whether a friend id_{i} is displayed.

It's guaranteed that no two queries of the first type will have the same id_{i} becuase one friend can't become online twice. Also, it's guaranteed that at least one query will be of the second type (type_{i} = 2) so the output won't be empty.

-----Output-----

For each query of the second type print one line with the answer — "YES" (without quotes) if the given friend is displayed and "NO" (without quotes) otherwise.

-----Examples-----
Input
4 2 8
300 950 500 200
1 3
2 4
2 3
1 1
1 2
2 1
2 2
2 3

Output
NO
YES
NO
YES
YES

Input
6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3

Output
NO
YES
NO
YES

-----Note-----

In the first sample, Limak has 4 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 8 queries:  "1 3" — Friend 3 becomes online.  "2 4" — We should check if friend 4 is displayed. He isn't even online and thus we print "NO".  "2 3" — We should check if friend 3 is displayed. Right now he is the only friend online and the system displays him. We should print "YES".  "1 1" — Friend 1 becomes online. The system now displays both friend 1 and friend 3.  "1 2" — Friend 2 becomes online. There are 3 friends online now but we were given k = 2 so only two friends can be displayed. Limak has worse relation with friend 1 than with other two online friends (t_1 < t_2, t_3) so friend 1 won't be displayed  "2 1" — Print "NO".  "2 2" — Print "YES".  "2 3" — Print "YES".


The employees of the R1 company often spend time together: they watch football, they go camping, they solve contests. So, it's no big deal that sometimes someone pays for someone else.

Today is the day of giving out money rewards. The R1 company CEO will invite employees into his office one by one, rewarding each one for the hard work this month. The CEO knows who owes money to whom. And he also understands that if he invites person x to his office for a reward, and then immediately invite person y, who has lent some money to person x, then they can meet. Of course, in such a situation, the joy of person x from his brand new money reward will be much less. Therefore, the R1 CEO decided to invite the staff in such an order that the described situation will not happen for any pair of employees invited one after another.

However, there are a lot of employees in the company, and the CEO doesn't have a lot of time. Therefore, the task has been assigned to you. Given the debt relationships between all the employees, determine in which order they should be invited to the office of the R1 company CEO, or determine that the described order does not exist.

-----Input-----

The first line contains space-separated integers n and m $(2 \leq n \leq 3 \cdot 10^{4} ; 1 \leq m \leq \operatorname{min}(10^{5}, \frac{n(n - 1)}{2}))$ — the number of employees in R1 and the number of debt relations. Each of the following m lines contains two space-separated integers a_{i}, b_{i} (1 ≤ a_{i}, b_{i} ≤ n; a_{i} ≠ b_{i}), these integers indicate that the person number a_{i} owes money to a person a number b_{i}. Assume that all the employees are numbered from 1 to n.

It is guaranteed that each pair of people p, q is mentioned in the input data at most once. In particular, the input data will not contain pairs p, q and q, p simultaneously.

-----Output-----

Print -1 if the described order does not exist. Otherwise, print the permutation of n distinct integers. The first number should denote the number of the person who goes to the CEO office first, the second number denote the person who goes second and so on.

If there are multiple correct orders, you are allowed to print any of them.

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

Output
2 1

Input
3 3
1 2
2 3
3 1

Output
2 1 3


Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one).

Players take turns, Alice is first. Each player during his or her turn has to move the chip 1, 2 or k cells to the left (so, if the chip is currently in the cell i, the player can move it into cell i - 1, i - 2 or i - k). The chip should not leave the borders of the paper strip: it is impossible, for example, to move it k cells to the left if the current cell has number i < k. The player who can't make a move loses the game.

Who wins if both participants play optimally?

Alice and Bob would like to play several games, so you should determine the winner in each game.

-----Input-----

The first line contains the single integer T (1 ≤ T ≤ 100) — the number of games. Next T lines contain one game per line. All games are independent.

Each of the next T lines contains two integers n and k (0 ≤ n ≤ 10^9, 3 ≤ k ≤ 10^9) — the length of the strip and the constant denoting the third move, respectively.

-----Output-----

For each game, print Alice if Alice wins this game and Bob otherwise.

-----Example-----
Input
4
0 3
3 3
3 4
4 4

Output
Bob
Alice
Bob
Alice


There are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads.

Theon and Yara Greyjoy are on a horse in the first city, they are starting traveling through the roads. But the weather is foggy, so they can’t see where the horse brings them. When the horse reaches a city (including the first one), it goes to one of the cities connected to the current city. But it is a strange horse, it only goes to cities in which they weren't before. In each such city, the horse goes with equal probabilities and it stops when there are no such cities.

Let the length of each road be 1. The journey starts in the city 1. What is the expected length (expected value of length) of their journey? You can read about expected (average) value by the link https://en.wikipedia.org/wiki/Expected_value.

-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 100000) — number of cities.

Then n - 1 lines follow. The i-th line of these lines contains two integers u_{i} and v_{i} (1 ≤ u_{i}, v_{i} ≤ n, u_{i} ≠ v_{i}) — the cities connected by the i-th road.

It is guaranteed that one can reach any city from any other by the roads.

-----Output-----

Print a number — the expected length of their journey. The journey starts in the city 1.

Your answer will be considered correct if its absolute or relative error does not exceed 10^{ - 6}.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if $\frac{|a - b|}{\operatorname{max}(1, b)} \leq 10^{-6}$.

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

Output
1.500000000000000

Input
5
1 2
1 3
3 4
2 5

Output
2.000000000000000

-----Note-----

In the first sample, their journey may end in cities 3 or 4 with equal probability. The distance to city 3 is 1 and to city 4 is 2, so the expected length is 1.5.

In the second sample, their journey may end in city 4 or 5. The distance to the both cities is 2, so the expected length is 2.


There is a special offer in Vasya's favourite supermarket: if the customer buys $a$ chocolate bars, he or she may take $b$ additional bars for free. This special offer can be used any number of times.

Vasya currently has $s$ roubles, and he wants to get as many chocolate bars for free. Each chocolate bar costs $c$ roubles. Help Vasya to calculate the maximum possible number of chocolate bars he can get!

-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of testcases.

Each of the next $t$ lines contains four integers $s, a, b, c~(1 \le s, a, b, c \le 10^9)$ — the number of roubles Vasya has, the number of chocolate bars you have to buy to use the special offer, the number of bars you get for free, and the cost of one bar, respectively.

-----Output-----

Print $t$ lines. $i$-th line should contain the maximum possible number of chocolate bars Vasya can get in $i$-th test.

-----Example-----
Input
2
10 3 1 1
1000000000 1 1000000000 1

Output
13
1000000001000000000

-----Note-----

In the first test of the example Vasya can buy $9$ bars, get $3$ for free, buy another bar, and so he will get $13$ bars.

In the second test Vasya buys $1000000000$ bars and gets $1000000000000000000$ for free. So he has $1000000001000000000$ bars.


Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joining some pairs of brains together. It was observed that the intellectual abilities of a zombie depend mainly on the topology of its nervous system. More precisely, we define the distance between two brains u and v (1 ≤ u, v ≤ n) as the minimum number of brain connectors used when transmitting a thought between these two brains. The brain latency of a zombie is defined to be the maximum distance between any two of its brains. Researchers conjecture that the brain latency is the crucial parameter which determines how smart a given zombie is. Help them test this conjecture by writing a program to compute brain latencies of nervous systems.

In this problem you may assume that any nervous system given in the input is valid, i.e., it satisfies conditions (1) and (2) from the easy version.

-----Input-----

The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 100000) denoting the number of brains (which are conveniently numbered from 1 to n) and the number of brain connectors in the nervous system, respectively. In the next m lines, descriptions of brain connectors follow. Every connector is given as a pair of brains a b it connects (1 ≤ a, b ≤ n and a ≠ b).

-----Output-----

Print one number – the brain latency.

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

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

Output
3


Since Sonya is interested in robotics too, she decided to construct robots that will read and recognize numbers.

Sonya has drawn $n$ numbers in a row, $a_i$ is located in the $i$-th position. She also has put a robot at each end of the row (to the left of the first number and to the right of the last number). Sonya will give a number to each robot (they can be either same or different) and run them. When a robot is running, it is moving toward to another robot, reading numbers in the row. When a robot is reading a number that is equal to the number that was given to that robot, it will turn off and stay in the same position.

Sonya does not want robots to break, so she will give such numbers that robots will stop before they meet. That is, the girl wants them to stop at different positions so that the first robot is to the left of the second one.

For example, if the numbers $[1, 5, 4, 1, 3]$ are written, and Sonya gives the number $1$ to the first robot and the number $4$ to the second one, the first robot will stop in the $1$-st position while the second one in the $3$-rd position. In that case, robots will not meet each other. As a result, robots will not be broken. But if Sonya gives the number $4$ to the first robot and the number $5$ to the second one, they will meet since the first robot will stop in the $3$-rd position while the second one is in the $2$-nd position.

Sonya understands that it does not make sense to give a number that is not written in the row because a robot will not find this number and will meet the other robot.

Sonya is now interested in finding the number of different pairs that she can give to robots so that they will not meet. In other words, she wants to know the number of pairs ($p$, $q$), where she will give $p$ to the first robot and $q$ to the second one. Pairs ($p_i$, $q_i$) and ($p_j$, $q_j$) are different if $p_i\neq p_j$ or $q_i\neq q_j$.

Unfortunately, Sonya is busy fixing robots that broke after a failed launch. That is why she is asking you to find the number of pairs that she can give to robots so that they will not meet.

-----Input-----

The first line contains a single integer $n$ ($1\leq n\leq 10^5$) — the number of numbers in a row.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1\leq a_i\leq 10^5$) — the numbers in a row.

-----Output-----

Print one number — the number of possible pairs that Sonya can give to robots so that they will not meet.

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

Output
9

Input
7
1 2 1 1 1 3 2

Output
7

-----Note-----

In the first example, Sonya can give pairs ($1$, $1$), ($1$, $3$), ($1$, $4$), ($1$, $5$), ($4$, $1$), ($4$, $3$), ($5$, $1$), ($5$, $3$), and ($5$, $4$).

In the second example, Sonya can give pairs ($1$, $1$), ($1$, $2$), ($1$, $3$), ($2$, $1$), ($2$, $2$), ($2$, $3$), and ($3$, $2$).


Omkar is playing his favorite pixelated video game, Bed Wars! In Bed Wars, there are $n$ players arranged in a circle, so that for all $j$ such that $2 \leq j \leq n$, player $j - 1$ is to the left of the player $j$, and player $j$ is to the right of player $j - 1$. Additionally, player $n$ is to the left of player $1$, and player $1$ is to the right of player $n$.

Currently, each player is attacking either the player to their left or the player to their right. This means that each player is currently being attacked by either $0$, $1$, or $2$ other players. A key element of Bed Wars strategy is that if a player is being attacked by exactly $1$ other player, then they should logically attack that player in response. If instead a player is being attacked by $0$ or $2$ other players, then Bed Wars strategy says that the player can logically attack either of the adjacent players.

Unfortunately, it might be that some players in this game are not following Bed Wars strategy correctly. Omkar is aware of whom each player is currently attacking, and he can talk to any amount of the $n$ players in the game to make them instead attack another player  — i. e. if they are currently attacking the player to their left, Omkar can convince them to instead attack the player to their right; if they are currently attacking the player to their right, Omkar can convince them to instead attack the player to their left.

Omkar would like all players to be acting logically. Calculate the minimum amount of players that Omkar needs to talk to so that after all players he talked to (if any) have changed which player they are attacking, all players are acting logically according to Bed Wars strategy.

-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The descriptions of the test cases follows.

The first line of each test case contains one integer $n$ ($3 \leq n \leq 2 \cdot 10^5$)  — the amount of players (and therefore beds) in this game of Bed Wars.

The second line of each test case contains a string $s$ of length $n$. The $j$-th character of $s$ is equal to L if the $j$-th player is attacking the player to their left, and R if the $j$-th player is attacking the player to their right.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

-----Output-----

For each test case, output one integer: the minimum number of players Omkar needs to talk to to make it so that all players are acting logically according to Bed Wars strategy.

It can be proven that it is always possible for Omkar to achieve this under the given constraints.

-----Example-----
Input
5
4
RLRL
6
LRRRRL
8
RLLRRRLL
12
LLLLRRLRRRLL
5
RRRRR

Output
0
1
1
3
2

-----Note-----

In the first test case, players $1$ and $2$ are attacking each other, and players $3$ and $4$ are attacking each other. Each player is being attacked by exactly $1$ other player, and each player is attacking the player that is attacking them, so all players are already being logical according to Bed Wars strategy and Omkar does not need to talk to any of them, making the answer $0$.

In the second test case, not every player acts logically: for example, player $3$ is attacked only by player $2$, but doesn't attack him in response. Omkar can talk to player $3$ to convert the attack arrangement to LRLRRL, in which you can see that all players are being logical according to Bed Wars strategy, making the answer $1$.


Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color c_{i}, connecting vertex a_{i} and b_{i}.

Mr. Kitayuta wants you to process the following q queries.

In the i-th query, he gives you two integers — u_{i} and v_{i}.

Find the number of the colors that satisfy the following condition: the edges of that color connect vertex u_{i} and vertex v_{i} directly or indirectly.

-----Input-----

The first line of the input contains space-separated two integers — n and m (2 ≤ n ≤ 100, 1 ≤ m ≤ 100), denoting the number of the vertices and the number of the edges, respectively.

The next m lines contain space-separated three integers — a_{i}, b_{i} (1 ≤ a_{i} < b_{i} ≤ n) and c_{i} (1 ≤ c_{i} ≤ m). Note that there can be multiple edges between two vertices. However, there are no multiple edges of the same color between two vertices, that is, if i ≠ j, (a_{i}, b_{i}, c_{i}) ≠ (a_{j}, b_{j}, c_{j}).

The next line contains a integer — q (1 ≤ q ≤ 100), denoting the number of the queries.

Then follows q lines, containing space-separated two integers — u_{i} and v_{i} (1 ≤ u_{i}, v_{i} ≤ n). It is guaranteed that u_{i} ≠ v_{i}.

-----Output-----

For each query, print the answer in a separate line.

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

Output
2
1
0

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

Output
1
1
1
1
2

-----Note-----

Let's consider the first sample.  [Image]   The figure above shows the first sample.    Vertex 1 and vertex 2 are connected by color 1 and 2.  Vertex 3 and vertex 4 are connected by color 3.  Vertex 1 and vertex 4 are not connected by any single color.


Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p_1, p_2, ..., p_{n}], where p_{i} denotes the number of page that should be read i-th in turn.

Sometimes Vladik’s mom sorted some subsegment of permutation P from position l to position r inclusive, because she loves the order. For every of such sorting Vladik knows number x — what index of page in permutation he should read. He is wondered if the page, which he will read after sorting, has changed. In other words, has p_{x} changed? After every sorting Vladik return permutation to initial state, so you can assume that each sorting is independent from each other.

-----Input-----

First line contains two space-separated integers n, m (1 ≤ n, m ≤ 10^4) — length of permutation and number of times Vladik's mom sorted some subsegment of the book.

Second line contains n space-separated integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — permutation P. Note that elements in permutation are distinct.

Each of the next m lines contains three space-separated integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ x_{i} ≤ r_{i} ≤ n) — left and right borders of sorted subsegment in i-th sorting and position that is interesting to Vladik.

-----Output-----

For each mom’s sorting on it’s own line print "Yes", if page which is interesting to Vladik hasn't changed, or "No" otherwise.

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

Output
Yes
No
Yes
Yes
No

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

Output
Yes
No
Yes
No
Yes

-----Note-----

Explanation of first test case:   [1, 2, 3, 4, 5] — permutation after sorting, 3-rd element hasn’t changed, so answer is "Yes".  [3, 4, 5, 2, 1] — permutation after sorting, 1-st element has changed, so answer is "No".  [5, 2, 3, 4, 1] — permutation after sorting, 3-rd element hasn’t changed, so answer is "Yes".  [5, 4, 3, 2, 1] — permutation after sorting, 4-th element hasn’t changed, so answer is "Yes".  [5, 1, 2, 3, 4] — permutation after sorting, 3-rd element has changed, so answer is "No".


We just discovered a new data structure in our research group: a suffix three!

It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in.

It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms.

Let us tell you how it works.

  If a sentence ends with "po" the language is Filipino.  If a sentence ends with "desu" or "masu" the language is Japanese.  If a sentence ends with "mnida" the language is Korean.

Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean.

Oh, did I say three suffixes? I meant four.

-----Input-----

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

Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least $1$ and at most $1000$ characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above.

-----Output-----

For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language.

-----Example-----
Input
8
kamusta_po
genki_desu
ohayou_gozaimasu
annyeong_hashimnida
hajime_no_ippo
bensamu_no_sentou_houhou_ga_okama_kenpo
ang_halaman_doon_ay_sarisari_singkamasu
si_roy_mustang_ay_namamasu

Output
FILIPINO
JAPANESE
JAPANESE
KOREAN
FILIPINO
FILIPINO
JAPANESE
JAPANESE

-----Note-----

The first sentence ends with "po", so it is written in Filipino.

The second and third sentences end with "desu" and "masu", so they are written in Japanese.

The fourth sentence ends with "mnida", so it is written in Korean.


Vasya has a sequence $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number $6$ $(\dots 00000000110_2)$ into $3$ $(\dots 00000000011_2)$, $12$ $(\dots 000000001100_2)$, $1026$ $(\dots 10000000010_2)$ and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with bitwise exclusive or of all elements equal to $0$.

For the given sequence $a_1, a_2, \ldots, a_n$ Vasya'd like to calculate number of integer pairs $(l, r)$ such that $1 \le l \le r \le n$ and sequence $a_l, a_{l + 1}, \dots, a_r$ is good.

-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 3 \cdot 10^5$) — length of the sequence.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^{18}$) — the sequence $a$.

-----Output-----

Print one integer — the number of pairs $(l, r)$ such that $1 \le l \le r \le n$ and the sequence $a_l, a_{l + 1}, \dots, a_r$ is good.

-----Examples-----
Input
3
6 7 14

Output
2

Input
4
1 2 1 16

Output
4

-----Note-----

In the first example pairs $(2, 3)$ and $(1, 3)$ are valid. Pair $(2, 3)$ is valid since $a_2 = 7 \rightarrow 11$, $a_3 = 14 \rightarrow 11$ and $11 \oplus 11 = 0$, where $\oplus$ — bitwise exclusive or. Pair $(1, 3)$ is valid since $a_1 = 6 \rightarrow 3$, $a_2 = 7 \rightarrow 13$, $a_3 = 14 \rightarrow 14$ and $3 \oplus 13 \oplus 14 = 0$.

In the second example pairs $(1, 2)$, $(2, 3)$, $(3, 4)$ and $(1, 4)$ are valid.


Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.

The park can be represented as a connected graph with $n$ nodes and $m$ bidirectional edges. Initially Bob is at the node $1$ and he records $1$ on his notebook. He can wander from one node to another through those bidirectional edges. Whenever he visits a node not recorded on his notebook, he records it. After he visits all nodes at least once, he stops wandering, thus finally a permutation of nodes $a_1, a_2, \ldots, a_n$ is recorded.

Wandering is a boring thing, but solving problems is fascinating. Bob wants to know the lexicographically smallest sequence of nodes he can record while wandering. Bob thinks this problem is trivial, and he wants you to solve it.

A sequence $x$ is lexicographically smaller than a sequence $y$ if and only if one of the following holds:   $x$ is a prefix of $y$, but $x \ne y$ (this is impossible in this problem as all considered sequences have the same length);  in the first position where $x$ and $y$ differ, the sequence $x$ has a smaller element than the corresponding element in $y$.

-----Input-----

The first line contains two positive integers $n$ and $m$ ($1 \leq n, m \leq 10^5$), denoting the number of nodes and edges, respectively.

The following $m$ lines describe the bidirectional edges in the graph. The $i$-th of these lines contains two integers $u_i$ and $v_i$ ($1 \leq u_i, v_i \leq n$), representing the nodes the $i$-th edge connects.

Note that the graph can have multiple edges connecting the same two nodes and self-loops. It is guaranteed that the graph is connected.

-----Output-----

Output a line containing the lexicographically smallest sequence $a_1, a_2, \ldots, a_n$ Bob can record.

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

Output
1 2 3

Input
5 5
1 4
3 4
5 4
3 2
1 5

Output
1 4 3 2 5

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

Output
1 4 3 7 9 8 6 5 2 10

-----Note-----

In the first sample, Bob's optimal wandering path could be $1 \rightarrow 2 \rightarrow 1 \rightarrow 3$. Therefore, Bob will obtain the sequence $\{1, 2, 3\}$, which is the lexicographically smallest one.

In the second sample, Bob's optimal wandering path could be $1 \rightarrow 4 \rightarrow 3 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 1 \rightarrow 5$. Therefore, Bob will obtain the sequence $\{1, 4, 3, 2, 5\}$, which is the lexicographically smallest one.


You are the gym teacher in the school.

There are $n$ students in the row. And there are two rivalling students among them. The first one is in position $a$, the second in position $b$. Positions are numbered from $1$ to $n$ from left to right.

Since they are rivals, you want to maximize the distance between them. If students are in positions $p$ and $s$ respectively, then distance between them is $|p - s|$.

You can do the following operation at most $x$ times: choose two adjacent (neighbouring) students and swap them.

Calculate the maximum distance between two rivalling students after at most $x$ swaps.

-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.

The only line of each test case contains four integers $n$, $x$, $a$ and $b$ ($2 \le n \le 100$, $0 \le x \le 100$, $1 \le a, b \le n$, $a \neq b$) — the number of students in the row, the number of swaps which you can do, and positions of first and second rivaling students respectively.

-----Output-----

For each test case print one integer — the maximum distance between two rivaling students which you can obtain.

-----Example-----
Input
3
5 1 3 2
100 33 100 1
6 0 2 3

Output
2
99
1

-----Note-----

In the first test case you can swap students in positions $3$ and $4$. And then the distance between the rivals is equal to $|4 - 2| = 2$.

In the second test case you don't have to swap students.

In the third test case you can't swap students.


A flowerbed has many flowers and two fountains.

You can adjust the water pressure and set any values r_1(r_1 ≥ 0) and r_2(r_2 ≥ 0), giving the distances at which the water is spread from the first and second fountain respectively. You have to set such r_1 and r_2 that all the flowers are watered, that is, for each flower, the distance between the flower and the first fountain doesn't exceed r_1, or the distance to the second fountain doesn't exceed r_2. It's OK if some flowers are watered by both fountains.

You need to decrease the amount of water you need, that is set such r_1 and r_2 that all the flowers are watered and the r_1^2 + r_2^2 is minimum possible. Find this minimum value.

-----Input-----

The first line of the input contains integers n, x_1, y_1, x_2, y_2 (1 ≤ n ≤ 2000,  - 10^7 ≤ x_1, y_1, x_2, y_2 ≤ 10^7) — the number of flowers, the coordinates of the first and the second fountain.

Next follow n lines. The i-th of these lines contains integers x_{i} and y_{i} ( - 10^7 ≤ x_{i}, y_{i} ≤ 10^7) — the coordinates of the i-th flower.

It is guaranteed that all n + 2 points in the input are distinct.

-----Output-----

Print the minimum possible value r_1^2 + r_2^2. Note, that in this problem optimal answer is always integer.

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

Output
6

Input
4 0 0 5 0
9 4
8 3
-1 0
1 4

Output
33

-----Note-----

The first sample is (r_1^2 = 5, r_2^2 = 1): $0^{\circ}$ The second sample is (r_1^2 = 1, r_2^2 = 32): [Image]


Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:

  $1 \le u < v \le n$.  $a_u > a_v$.

Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $(u_i, v_i)$ with the following conditions:

  all the pairs in the list are distinct and form an inversion in $a$.  all the pairs that form an inversion in $a$ are in the list.  Starting from the given array, if you swap the values at indices $u_1$ and $v_1$, then the values at indices $u_2$ and $v_2$ and so on, then after all pairs are processed, the array $a$ will be sorted in non-decreasing order.

Construct such a list or determine that no such list exists. If there are multiple possible answers, you may find any of them.

-----Input-----

The first line of the input contains a single integer $n$ ($1 \le n \le 1000$) — the length of the array.

Next line contains $n$ integers $a_1,a_2,...,a_n$ $(1 \le a_i \le 10^9)$  — elements of the array.

-----Output-----

Print -1 if no such list exists. Otherwise in the first line you should print a single integer $m$ ($0 \le m \le \dfrac{n(n-1)}{2}$) — number of pairs in the list.

The $i$-th of the following $m$ lines should contain two integers $u_i, v_i$ ($1 \le u_i < v_i\le n$).

If there are multiple possible answers, you may find any of them.

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

Output
2
1 3
1 2

Input
4
1 8 1 6

Output
2
2 4
2 3

Input
5
1 1 1 2 2

Output
0

-----Note-----

In the first sample test case the array will change in this order $[3,1,2] \rightarrow [2,1,3] \rightarrow [1,2,3]$.

In the second sample test case it will be $[1,8,1,6] \rightarrow [1,6,1,8] \rightarrow [1,1,6,8]$.

In the third sample test case the array is already sorted.


Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a_1, a_2, ..., a_{n} in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it G) initially has n vertices and 0 edges. During Bubble Sort execution, edges appear as described in the following algorithm (pseudocode).

procedure bubbleSortGraph()

    build a graph G with n vertices and 0 edges

    repeat

        swapped = false

        for i = 1 to n - 1 inclusive do:

            if a[i] > a[i + 1] then

                add an undirected edge in G between a[i] and a[i + 1]

                swap( a[i], a[i + 1] )

                swapped = true

            end if

        end for

    until not swapped

    /* repeat the algorithm as long as swapped value is true. */

end procedure

For a graph, an independent set is a set of vertices in a graph, no two of which are adjacent (so there are no edges between vertices of an independent set). A maximum independent set is an independent set which has maximum cardinality. Given the permutation, find the size of the maximum independent set of graph G, if we use such permutation as the premutation a in procedure bubbleSortGraph.

-----Input-----

The first line of the input contains an integer n (2 ≤ n ≤ 10^5). The next line contains n distinct integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ n).

-----Output-----

Output a single integer — the answer to the problem.

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

Output
2

-----Note-----

Consider the first example. Bubble sort swaps elements 3 and 1. We add edge (1, 3). Permutation is now [1, 3, 2]. Then bubble sort swaps elements 3 and 2. We add edge (2, 3). Permutation is now sorted. We have a graph with 3 vertices and 2 edges (1, 3) and (2, 3). Its maximal independent set is [1, 2].


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

Could you pass the interview in the machine vision company in IT City?

-----Input-----

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

-----Output-----

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

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

Output
25


The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every coordinate of every vector is 1 or  - 1 and any two vectors are orthogonal. Just as a reminder, two vectors in n-dimensional space are considered to be orthogonal if and only if their scalar product is equal to zero, that is: $\sum_{i = 1}^{n} a_{i} \cdot b_{i} = 0$.

Danil quickly managed to come up with the solution for this problem and the teacher noticed that the problem can be solved in a more general case for 2^{k} vectors in 2^{k}-dimensinoal space. When Danil came home, he quickly came up with the solution for this problem. Can you cope with it?

-----Input-----

The only line of the input contains a single integer k (0 ≤ k ≤ 9).

-----Output-----

Print 2^{k} lines consisting of 2^{k} characters each. The j-th character of the i-th line must be equal to ' * ' if the j-th coordinate of the i-th vector is equal to  - 1, and must be equal to ' + ' if it's equal to  + 1. It's guaranteed that the answer always exists.

If there are many correct answers, print any.

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

Output
++**
+*+*
++++
+**+

-----Note-----

Consider all scalar products in example:  Vectors 1 and 2: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( + 1) + ( - 1)·( - 1) = 0  Vectors 1 and 3: ( + 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) + ( - 1)·( + 1) = 0  Vectors 1 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( - 1) + ( - 1)·( + 1) = 0  Vectors 2 and 3: ( + 1)·( + 1) + ( - 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) = 0  Vectors 2 and 4: ( + 1)·( + 1) + ( - 1)·( - 1) + ( + 1)·( - 1) + ( - 1)·( + 1) = 0  Vectors 3 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( + 1)·( - 1) + ( + 1)·( + 1) = 0


In Aramic language words can only represent objects.

Words in Aramic have special properties:   A word is a root if it does not contain the same letter more than once.  A root and all its permutations represent the same object.  The root $x$ of a word $y$ is the word that contains all letters that appear in $y$ in a way that each letter appears once. For example, the root of "aaaa", "aa", "aaa" is "a", the root of "aabb", "bab", "baabb", "ab" is "ab".  Any word in Aramic represents the same object as its root.

You have an ancient script in Aramic. What is the number of different objects mentioned in the script?

-----Input-----

The first line contains one integer $n$ ($1 \leq n \leq 10^3$) — the number of words in the script.

The second line contains $n$ words $s_1, s_2, \ldots, s_n$ — the script itself. The length of each string does not exceed $10^3$.

It is guaranteed that all characters of the strings are small latin letters.

-----Output-----

Output one integer — the number of different objects mentioned in the given ancient Aramic script.

-----Examples-----
Input
5
a aa aaa ab abb

Output
2
Input
3
amer arem mrea

Output
1

-----Note-----

In the first test, there are two objects mentioned. The roots that represent them are "a","ab".

In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer".