The activity of a panipuri seller is "making a panipuri and putting it on the palte of his customer".
$N$ customers are eating panipuri, Given an array $A$ of length $N$, $i^{th}$ customer takes $A_i$ seconds to eat a panipuri.
The Speed of Panipuri seller refers to the number of customers served per second. Determine the minimum speed of panipuri seller so that no customer has to wait for panipuri after getting his/her first panipuri.
Assume that the plate can hold infinite panipuris, and customer starts eating next panipuri just after finishing the current one.    You would be provided with the time taken by each customer to eat a panipuri.
Panpuri seller serves panipuri in round robin manner (first to last and then again first).

-----Input:-----
- First line will contain $T$, number of testcases. Then the test cases follow.
- For each test case, the first line contains $N$ number of customers.
- Then the second line will contain $N$ space separated integers, $A_1$ to $A_N$, eating time taken by each customer(in seconds).

-----Output:-----
- For each test case, print a single line containing the minimum integral speed of panipuri seller so that no customer has to wait.

-----Constraints-----
- $0 < T \leq 100$
- $0 < N \leq 10^6$
- $0 < A_i \leq 10^9$
- Sum of $N$ over all test cases does not exceed $10^6$

-----Sample Input:-----
2
4
2 4 6 3
5
2 3 4 6 5

-----Sample Output:-----
2

3

-----EXPLANATION:-----
$Test case$ $1$:

Let's assume speed of panipuri seller be 1.

So starting from $0^{th}$ second, in $0$ to $1$ second seller make a panipuri and put it into the plate of first customer, and first customer completely eat it in $1$ to $3$ second as he takes $2$ second to eat a panipuri. But in $3$ to $4$ second panipuri seller is serving to $4^{th}$ customer, and hence first customer have to wait, so 1 cannot be our answer.

Next possible speed can be $2$ .

Starting from $0^{th}$ second, at half second seller make a panipuri and put it into the plate of first customer,  first customer completely eat it on $2.5$ second as he takes $2$ second to eat a panipuri. In $0.5$ to $1$ second, seller serve the second customer. similarly in $1$ to $2$ second $3^{rd}$ and $4^{th}$ customer will be serve, in $2$ to $2.5$ second, seller will again serve the first customer so at $2.5$ sec $1^{st}$ customer will have a panipuri to eat.

Similarly proceeding further we will find that no customer have to wait when speed is $2$.


Chef Leonardo has a decimal integer $N$ and a non-zero decimal digit $d$. $N$ does not contain the digit zero; specifically, $N$ should always be treated as a decimal integer without leading zeroes.
Chef likes $d$ and does not like any other digit, so he decided to change $N$. He may apply the following operation any number of times (including zero): append the digit $d$ to the decimal representation of $N$ ($d$ becomes the least significant digit of $N$), then remove one occurrence of one digit from the decimal representation of $N$.
Chef has already changed a lot of numbers and he got bored. Now, he wants to know the smallest possible value of $N$ which can be obtained by performing the operation described above. Can you help him?

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains two space-separated integers $N$ and $d$.

-----Output-----
For each test case, print a single line containing one integer - the minimum number Chef can obtain.

-----Constraints-----
- $1 \le T \le 1,000$
- $1 \le N \le 10^{18}$
- $N$ does not contain the digit $0$
- $1 \le d \le 9$

-----Subtasks-----
Subtask #1 (40 points):
- $1 \le T \le 100$
- $1 \le N \le 10^9$
Subtask #2 (60 points): original constraints

-----Example Input-----
3
35 4
42 4
24 9

-----Example Output-----
34
24
24

-----Explanation-----
Example case 1: Chef can remove the digit $5$ and add $4$ to the end of $N$. Then, $N$ becomes $34$.
Example case 2: Chef can remove the digit $4$ from the beginning of $N$, add $4$ to the end of $N$ and get $N = 24$.
Example case 3: Chef cannot make his number any smaller.

question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer


Alice likes prime numbers. According to Alice, only those strings are nice whose sum of character values at a prime position is prime. She has a string $S$. Now, she has to count the number of nice strings which come before string $S$( including $S$) in the dictionary and are of the same length as $S$.
Strings are zero-indexed from left to right.
To find the character value she uses the mapping {'a': 0, 'b':1, 'c':2 ……. 'y': 24, 'z':25} .
For example, for string $abcde$ Characters at prime positions are $'c'$ and $'d'$. c + d = 2 + 3 = 5. Since, 5 is a prime number, the string is $nice$.
Since there could be many nice strings print the answer modulo $10^{9}+7$.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- Each testcase contains of a single line of input, the string $S$.

-----Output:-----
For each testcase, output in a single line number of nice strings modulo $10^{9}+7$.

-----Constraints-----
- $1 \leq T \leq 10$
- $2 \leq |S| \leq 10^2$
String $S$ contains only lowercase letters.

-----Sample Input:-----
1
abc

-----Sample Output:-----
10


Chef has a garden with $N$ plants arranged in a line in decreasing order of height. Initially the height of the plants are $A_1, A_2, ..., A_N$.
The plants are growing, after each hour the height of the $i$-th plant increases by $i$ millimeters. Find the minimum number of integer hours that Chef must wait to have two plants of the same height.

-----Input:-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space separated integers $A_1,A_2,..A_N$.

-----Output:-----
For each test case print a single line containing one integer, the minimum number of integer hours that Chef must wait to have two plants of the same height.

-----Constraints-----
- $1 \leq T \leq 1000$
- $2 \leq N \leq 10^5$
- $0\leq A_i \leq 10^{18}$
- $A_i >A_{i+1}$, for each valid $i$
- The Sum of $N$ over all test cases does not exceed $10^6$

-----Sample Input:-----
1
3
8 4 2

-----Sample Output:-----
2

-----EXPLANATION:-----
After $2$ hours there are two plants with the same height.
$[8,4,2] \rightarrow [9,6,5] \rightarrow [10,8,8]$.


Note : This question carries $100$ $points$
CodeLand is celebrating a festival by baking cakes! In order to avoid wastage, families follow a unique way of distributing cakes.
For $T$ families in the locality, $i$-th family (1 <= $i$ <= $T$) has $N$ members. They baked $S$ slices of cakes. The smallest member of the family gets $K$ slices of cakes. Each family has a lucky number of $R$ and they agree to distribute the slices such that the member gets $R$ times more slices than the member just smaller than them. Since the family is busy in festival preparations, find out if the number of slices would be sufficient for the family or not. Also, find how many extra slices they have or how many slices are they short of.
Also, the locality is kind and believes in sharing. So, you also need to determine if each family would have sufficient slices if families shared their cakes among each other!

-----Input :-----
- First line of input will have a single integer $T$ i.e. the number of families in the locality
- For next $T$ lines, each line will describe one family through 4 integers i.e. $S$, $N$, $K$, $R$ separated by spaces

-----Output-----
- First $T$ lines of output will show if slices are enough for the family or not, followed by extra or required slices. For example, if slices are sufficient, the output would be $POSSIBLE$ $10$ which implies 10 slices are extra. If slices are insufficient, the output would be $IMPOSSIBLE$ $15$ which implies 15 slices are required to fulfill the requirement.
- Last line of output would be $IMPOSSIBLE$ or $POSSIBLE$ depending on whether each family would get enough slices after sharing.

-----Constraints:-----
- 1 ≤ $T$ ≤ 50
- 1 ≤ $N$ ≤ 15
- 1 ≤ $S$ ≤ 10^9
- 1 ≤ $K$ ≤ 5
- 1 ≤ $R$ ≤ 5

-----Sample Input:-----
5
100 4 2 2
100 4 3 2
100 4 3 3
200 4 4 2
10 3 2 2

-----Sample Output:-----
POSSIBLE 70
POSSIBLE 55
IMPOSSIBLE 20
POSSIBLE 140
IMPOSSIBLE 4
POSSIBLE

-----Explanation-----
For the first home, the youngest member has got 2 slices, the one older than them gets 2 times more slices, and so forth. So, first home needs 2 + 4 + 8 + 16 = 30 slices. But since they made 100, they have 70 extra, hence we print 'POSSIBLE 70'.
Doing the same for other houses, we find 20 + 4 = 24 slices extra are required so that all families have enough slices. In this case we have 70 + 55 + 140 = 265 extra slices which is > 24, so we print 'POSSIBLE' in last line.

POSSIBLE 70
POSSIBLE 55
IMPOSSIBLE 20
POSSIBLE 140
IMPOSSIBLE 4
POSSIBLE


Let's consider a rooted binary tree with the following properties:
- The number of nodes and edges in the tree is infinite
- The tree root is labeled by $1$
- A node labeled by $v$ has two children: $2 \cdot v$ (the left child of $v$), and $2 \cdot v + 1$ (the right child of $v$).
Here is an image of the first several layers of such a tree:

Let's consider four operations that you are allowed to apply during the tree traversal:
- move to the left child - move from $v$ to $2 \cdot v$
- move to the right child - move from $v$ to $2 \cdot v + 1$
- move to the parent as a left child - move from $v$ to $\frac{v}{2}$ if $v$ is an even integer
- move to the parent as a right child - move from $v$ to $\frac{v - 1}{2}$ if $v$ is an odd integer
It can be proven, that for any pair of nodes $u$ and $v$, there is only one sequence of commands that moves from $u$ to $v$ and visits each node of the tree at most once. Let's call such a sequence of commands a path configuration for a pair of nodes $(u, v)$.
You are asked to process a series of the following queries:
You are given three integers $n$, $u$ and $v$ ($1 \leq u, v \leq n$). Count the pairs of nodes $(w, t)$ ($1 \leq w, t \leq n$) such that the path configuration for $(w, t)$ is the same with the path configuration for $(u, v)$.

-----Input-----
- The first line of input contains a single integer $Q$, denoting the number of queries to process.
- Each of the next $Q$ lines contains three space-separated integers $n$, $u$ and $v$ denoting a query.

-----Output-----
For each query, print the answer on a separate line.

-----Constraints-----
- $1 \leq Q \leq 2 \cdot 10^4$
- $1 \leq u, v \leq n \leq 10^{9}$

-----Example Input-----
3
11 9 11
10 2 2
8 1 8

-----Example Output-----
2
10
1

-----Explanation-----
In the first query from the example test case, you should count pairs $(5, 7)$ and $(9, 11)$.
In the second query from the example test case, you should count the following pairs: $(1, 1)$, $(2, 2)$, $(3, 3)$, $(4, 4)$, $(5, 5)$, $(6, 6)$, $(7, 7)$, $(8, 8)$, $(9, 9)$ and $(10, 10)$.
In the third query from the example test case, you should only count a pair $(1, 8)$.


Two's company, three's a crowd!
It's been one year since Chef met his brother. Last year, his younger brother came to visit him during this time of the year. This year, the Chef is planning to go visit his brother. Chef's brother has planned to throw a "Welcome Party" for him. He wants to invite people from his neighbourhood (i.e. from the street where he lives). There are N houses on the street in a single line (not considering the brother's house). He wants the party to be fun and he will not like to invite people who might spoil the mood of the party. If people are invited from three consecutive houses on the street, they might create trouble. As they say, three's a crowd! He doesn't want to ruin the Chef's Welcome Party and so he will not want to send invites to any three consecutive houses. He wants you to tell him how many ways are there for him to go wrong. Note that he can play safe by not inviting anyone to avoid a crowd.

-----Input:-----
First line of the input contains a single integer T, the number of test cases.

Each test case contains a line containing a single integer N described above.

-----Output:-----
For each test case output a single integer denoting the number of ways the brother can go wrong with planning the party.

The answer can get quite large. So output the total number of ways modulo 109+7.

-----Constraints:-----
1<=T<=10000
1<=N<=1015

-----Example:-----Input:
2
3
4

Output:
1
3

Explanation:
Case 1: The only way he can go wrong is by inviting all the houses.
Case 2: First way of getting wrong is by inviting houses (1,2,3). Second way to get wrong is by inviting houses (2,3,4). Third way of going wrong is by inviting all 4 houses i.e. (1,2,3,4).


You're given an integer N. Write a program to calculate the sum of all the digits of N.

-----Input-----

The first line contains an integer T, the total number of testcases. Then follow T lines, each line contains an integer N.

-----Output-----
For each test case, calculate the sum of digits of N, and display it in a new line.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 1000000

-----Example-----
Input
3
12345
31203
2123
Output
15
9
8


Chef has a binary array in an unsorted manner. Cheffina challenges chef to find the transition point in the sorted (ascending) binary array. Here indexing is starting from 0.
Note: Transition point always exists.

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains two lines of input, $N$.
- N space-separated binary numbers.

-----Output:-----
For each test case, output in a single line answer.

-----Constraints-----
- $1 \leq T \leq 10$
- $1 \leq N \leq 10^5$

-----Sample Input:-----
1
5
0 1 0 0 1

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

-----EXPLANATION:-----
binary array in sorted form will look like = [0, 0, 0, 1, 1]


You have an array A of size N containing only positive numbers. You have to output the maximum possible value of A[i]%A[j] where 1<=i,j<=N.

-----Input-----
The first line of each test case contains a single integer N denoting the size of the array. The next N lines contains integers A1, A2, ..., AN denoting the numbers

-----Output-----
Output a single integer answering what is asked in the problem.

-----Subtask 1 (20 points)-----
- 1 ≤ N ≤ 5000
- 1 ≤ A[i] ≤ 2*(10^9)

-----Subtask 2 (80 points)-----
- 1 ≤ N ≤ 1000000
- 1 ≤ A[i] ≤ 2*(10^9)

-----Example-----
Input:
2
1
2

Output:
1

-----Explanation-----
There will be four values, A[0]%A[0] = 0, A[0]%A[1]=1, A[1]%A[0]=0, A[1]%A[1]=0, and hence the output will be the maximum among them all, that is 1.


Chefland is a grid with N$N$ rows and M$M$ columns. Each cell of this grid is either empty or contains a house. The distance between a pair of houses is the Manhattan distance between the cells containing them.
For each d$d$ between 1$1$ and N+M−2$N+M-2$ inclusive, Chef wants to calculate the number of unordered pairs of distinct houses with distance equal to d$d$. Please help him!

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of each test case contains two space-separated integers N$N$ and M$M$.
- N$N$ lines follow. For each i$i$ (1≤i≤N$1 \le i \le N$), the i$i$-th of these lines contains a binary string with length M$M$; for each j$j$ (1≤j≤M$1 \le j \le M$), the j$j$-th character of this string is '1' if the cell in the i$i$-th row and j$j$-th column contains a house or '0' if it is empty.

-----Output-----
For each test case, print a single line containing N+M−2$N+M-2$ space-separated integers. For each valid i$i$, the i$i$-th integer should denote the number of pairs with distance i$i$.

-----Constraints-----
- 1≤T≤3$1 \le T \le 3$
- 2≤N,M≤300$2 \le N, M \le 300$

-----Subtasks-----
Subtask #1 (50 points): N,M≤50$N, M \le 50$
Subtask #2 (50 points): original constraints

-----Example Input-----
1
3 4
0011
0000
0100

-----Example Output-----
1 0 1 1 0


and Bengali as well.
There are N$N$ cats (numbered 1$1$ through N$N$) and M$M$ rats (numbered 1$1$ through M$M$) on a line. Each cat and each rat wants to move from some point to some (possibly the same) point on this line. Naturally, the cats also want to eat the rats when they get a chance. Both the cats and the rats can only move with constant speed 1$1$.
For each valid i$i$, the i$i$-th cat is initially sleeping at a point a_i$a_i$. At a time s_i$s_i$, this cat wakes up and starts moving to a final point b_i$b_i$ with constant velocity and without any detours (so it arrives at this point at the time e_i = s_i + |a_i-b_i|$e_i = s_i + |a_i-b_i|$). After it arrives at the point b_i$b_i$, it falls asleep again.
For each valid i$i$, the i$i$-th rat is initially hiding at a point c_i$c_i$. At a time r_i$r_i$, this rat stops hiding and starts moving to a final point d_i$d_i$ in the same way as the cats ― with constant velocity and without any detours, arriving at the time q_i = r_i + |c_i-d_i|$q_i = r_i + |c_i-d_i|$ (if it does not get eaten). After it arrives at the point d_i$d_i$, it hides again.
If a cat and a rat meet each other (they are located at the same point at the same time), the cat eats the rat, the rat disappears and cannot be eaten by any other cat. A sleeping cat cannot eat a rat and a hidden rat cannot be eaten ― formally, cat i$i$ can eat rat j$j$ only if they meet at a time t$t$ satisfying s_i \le t \le e_i$s_i \le t \le e_i$ and r_j \le t \le q_j$r_j \le t \le q_j$.
Your task is to find out which rats get eaten by which cats. It is guaranteed that no two cats will meet a rat at the same time.

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of each test case contains two space-separated integers N$N$ and M$M$.
- N$N$ lines follow. For each i$i$ (1 \le i \le N$1 \le i \le N$), the i$i$-th of these lines contains three space-separated integers a_i$a_i$, b_i$b_i$ and s_i$s_i$.
- M$M$ more lines follow. For each i$i$ (1 \le i \le M$1 \le i \le M$), the i$i$-th of these lines contains three space-separated integers c_i$c_i$, d_i$d_i$ and r_i$r_i$.

-----Output-----
For each test case, print M$M$ lines. For each valid i$i$, the i$i$-th of these lines should contain a single integer ― the number of the cat that will eat the i$i$-th rat, or -1$-1$ if no cat will eat this rat.

-----Constraints-----
- 1 \le T \le 10$1 \le T \le 10$
- 0 \le N \le 1,000$0 \le N \le 1,000$
- 1 \le M \le 1,000$1 \le M \le 1,000$
- 1 \le a_i, b_i, s_i \le 10^9$1 \le a_i, b_i, s_i \le 10^9$ for each valid i$i$
- 1 \le c_i, d_i, r_i \le 10^9$1 \le c_i, d_i, r_i \le 10^9$ for each valid i$i$
- all initial and final positions of all cats and rats are pairwise distinct

-----Example Input-----
2
8 7
2 5 1
1 4 1
9 14 10
20 7 9
102 99 1
199 202 1
302 299 3
399 402 3
6 3 1
10 15 10
100 101 1
201 200 1
300 301 5
401 400 5
1000 1010 1020
8 8
2 8 2
12 18 2
22 28 4
32 38 4
48 42 2
58 52 3
68 62 1
78 72 3
3 6 3
13 19 3
21 25 3
31 39 3
46 43 4
59 53 2
65 61 4
79 71 2

-----Example Output-----
1
4
5
6
7
8
-1
1
2
3
4
5
6
7
8


You are given an unweighted tree with N$N$ nodes (numbered 1$1$ through N$N$). Let's denote the distance between any two nodes p$p$ and q$q$ by d(p,q)$d(p, q)$.
You should answer Q$Q$ queries. In each query, you are given parameters a$a$, da$d_a$, b$b$, db$d_b$, and you should find a node x$x$ such that d(x,a)=da$d(x, a) = d_a$ and d(x,b)=db$d(x, b) = d_b$, or determine that there is no such node.

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of each test case contains two space-separated integers N$N$ and Q$Q$.
- Each of the next N−1$N-1$ lines contains two space-separated integers u$u$ and v$v$ denoting that nodes u$u$ and v$v$ are connected by an edge.
- Each of the next Q$Q$ lines contains four space-separated integers a$a$, da$d_a$, b$b$ and db$d_b$ describing a query.

-----Output-----
For each query, print a single line containing one integer ― the number of a node satisfying the given requirements, or −1$-1$ if no such node exists.
If there are multiple solutions, you may output any one.

-----Constraints-----
- 1≤T≤1,000$1 \le T \le 1,000$
- 1≤N,Q≤106$1 \le N, Q \le 10^6$
- 1≤u,v≤N$1 \le u, v \le N$
- the graph on the input is a tree
- 1≤a,b≤N$1 \le a, b \le N$
- 1≤da,db<N$1 \le d_a, d_b < N$
- the sum of N$N$ over all test cases does not exceed 106$10^6$
- the sum of Q$Q$ over all test cases does not exceed 106$10^6$

-----Subtasks-----
Subtask #1 (50 points):
- 1≤N,Q≤1,000$1 \le N, Q \le 1,000$
- the sum of N$N$ over all test cases does not exceed 1,000$1,000$
- the sum of Q$Q$ over all test cases does not exceed 1,000$1,000$
Subtask #2 (50 points): original constraints

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

-----Example Output-----
3
5
-1


$Jaggu$ monkey a friend of $Choota$ $Bheem$ a great warrior of $Dholakpur$. He gets everything he wants. Being a friend of $Choota$ $Bheem$ he never has to struggle for anything, because of this he is in a great debt of $Choota$ $Bheem$, he really wants to pay his debt off.
Finally the time has come to pay his debt off, $Jaggu$ is on a magical tree. He wants to collect apples from different branches but he is in a hurry. $Botakpur$ has attacked on $Dholakpur$ and $Bheem$ is severely injured, as been instructed by the village witch, $Bheem$ can only be saved by the apples of the magical tree. Each apple is placed in Tree Node structure and each apple has some sweetness. Now there's a problem as $Jaggu$ is also injured so he can only slide downwards and alse is collecting apples in his hand so he can't climb. You would be given $Q$ queries. Queries are of 2 type :-
-
Ending Node Node of $Jaggu$ is given. $format$ - type of query node -(1 2)
-
Sweetness of Apple on a given node is changed. $format$ - type of query node new sweetness(2 3 10)
$Note$: $Jaggu$ is always on the top of tree initially in each query.The sweetness is always positive.
Help $Jaggu$ in saving $Bheem$

-----Input:-----
- First line contains $N$ - (number of nodes).
- Next line contains $N$ integers with space giving sweetness of apple on Nodes $(1 to N)$
- Next $N-1$ lines contain  $N1$ $N2$ connected nodes.
- Next line contains single integer $Q$ Number of queries

-----Output:-----
- For each query of type 1, print total sweetness of apples.

-----Constraints-----
- $1 \leq N \leq 10^4$
- $2 \leq Q \leq 10^4$

-----Sample Input:-----
10
10 12 6 8 1 19 0 5 13 17
1 2
1 3
1 4
3 10
4 8
8 9
4 5
5 7
5 6
3
1 1
2 3 20
1 8

-----Sample Output:-----
10
23

-----EXPLANATION:-----
This sweetness array is :
$[10,2,6,8,1,19,0,5,13,17]$
The tree is:
1

/  |   \

2    3     4

/    /    \

10     8        5

/        /    \

9         7        6


You are given a sequence of n integers a1, a2, ..., an and an integer d.
Find the length of the shortest non-empty contiguous subsequence with sum of elements at least d. Formally, you should find the smallest positive integer k with the following property: there is an integer s (1 ≤ s ≤ N-k+1) such that as + as+1 + ... + as+k-1 ≥ d.

-----Input-----

- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains two space-separated integers n and d.
- The second line contains n space-separated integers a1, a2, ..., an.

-----Output-----
For each test case, print a single line containing one integer — the length of the shortest contiguous subsequence with sum of elements ≥ d. If there is no such subsequence, print -1 instead.

-----Constraints-----
- 1 ≤ T ≤ 105
- 1 ≤ n ≤ 105
- -109 ≤ d ≤ 109
- -104 ≤ ai ≤ 104
- 1 ≤ sum of n over all test cases ≤ 2 · 105

-----Example-----
Input:

2
5 5
1 2 3 1 -5
5 1
1 2 3 1 -5

Output:

2
1


Sinchan and his friends loves to eat. They have a 2D rectangular cake which they want to share. Sinchan is very kind and offers his friends to eat the cake first, all friends goes one by one to eat the cake. Each friend will cut cake into two parts. First part of the cake will be largest possible square from the cake, that the friend will eat, and will leave the second part for others, it continues untill cake is over or every friend gets to eat the cake.
Now Sinchan wonder how much cake would he be able to get.

-----Input-----
- First line of input contain T, denoting number of test case.
- First line of each test case contains N, denoting number of friends.
- Second line of test case contain L, B (L x B) denoting dimension of cake.

-----Output-----
- For each test case, if Sinchan gets to eat the cake print (without quotes) "Yes #" where # is area of cake that Sinchan gets. Otherwise print  (without quotes) "No"

-----Constraints-----
- 1 ≤ T, N, L, B ≤ 1000

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

Output:
Yes 2
No
Yes 1

-----Explanation-----
Example case 1. First friend divides 5x3 cake in 3x3 and 2x3 since 3x3 is largest possible square, second Friend divides 2x3 cake in 2x2 and 1x2 and eat 2x2 piece. Finaly Sinchan gets to eat and area of cake is 1*2 hence Output is (without quotes) "Yes 2"


Leha is a bright mathematician. Today he is investigating whether an integer is divisible by some square number or not.
He has a positive integer X represented as a product of N integers a1, a2, .... aN. He has somehow figured out that there exists some integer P such that the number X is divisible by P2, but he is not able to find such P himself. Can you find it for him? If there are more than one possible values of P possible, you can print any one of them.

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. T test cases follow.
The first line of each test case contains one integer N denoting the number of intgers in presentation of X.
The second line contains N space-separated integers a1, a2, .... aN.

-----Output-----
For each test case, output a single integer P deoting the answer for this test case. Note that P must be in range from 2 to 1018 inclusive. It's guaranteed that at least one answer exists. If there are more than one possible answers, print any.

-----Constraints-----
- 1 ≤ T ≤ 5
- 1 ≤ N ≤ 100
- 1 ≤ ai ≤ 1018

-----Subtasks-----
- Subtask 1[19 points]: 1 ≤ a1*a2*...*aN ≤ 106
- Subtask 2[22 points]: 1 ≤ a1*a2*...*aN ≤ 1012
- Subtask 3[23 points]: 1 ≤ ai ≤ 1012
- Subtask 4[36 points]: no additional constraints

-----Example-----
Input:
1
3
21 11 6

Output:
3

-----Explanation-----
Example case 1. X = 21 * 11 * 6 = 1386. It's divisible by 9 which is a square number, as 9 = 32. So P = 3.


Using his tip-top physique, Kim has now climbed up the mountain where the base is located. Kim has found the door to the (supposedly) super secret base. Well, it is super secret, but obviously no match for Kim's talents.
The door is guarded by a row of $N$ buttons. Every button has a single number $A_i$ written on it. Surprisingly, more than one button can have the same number on it. Kim recognises this as Soum's VerySafe door, for which you need to press two buttons to enter the password. More importantly, the sum of the two numbers on the buttons you press must be odd. Kim can obviously break through this door easily, but he also wants to know how many different pairs of buttons he can pick in order to break through the door.
Can you help Kim find the number of different pairs of buttons he can press to break through the door?
Note: Two pairs are considered different if any of the buttons pressed in the pair is different (by position of the button pressed). Two pairs are not considered different if they're the same position of buttons, pressed in a different order.
Please refer to the samples for more details.

-----Input:-----
- The first line contains a single integer $T$, representing the number of testcases. $2T$ lines follow, 2 for each testcase.
- For each testcase, the first line contains a single integer $N$, the number of buttons.
- The second line of each testcase contains $N$ space-separated integers, $A_1, A_2, \ldots, A_N$, representing the numbers written on each button.

-----Output:-----
Print a single number, $K$, representing the number of pairs of buttons in $A$ which have an odd sum.

-----Subtasks-----
For all subtasks,  $1 \leq T \leq 10$, $1 \leq N \leq 100000$, and $1 \leq A_i \leq 100000$ for all $A_i$.
Subtask 1 [15 points] : $N \leq 2$, There are at most 2 buttons
Subtask 2 [45 points] : $N \leq 1000$, There are at most 1000 buttons
Subtask 3 [40 points] : No additional constraints.

-----Sample Input:-----
3
4
3 5 3 4
2
5 7
1
4

-----Sample Output:-----
3
0
0

-----EXPLANATION:-----
This section uses 1-indexing.
In the first sample, the buttons are: $[3, 5, 3, 4]$
$A[1] +  A[4] = 3 + 4 = 7$ which is odd.
$A[2] +  A[4] = 5 + 4 = 9$ which is odd.
$A[3] +  A[4] = 3 + 4 = 7$ which is odd.
In total, there are 3 pairs with an odd sum, so the answer is 3.
In the second sample, the buttons are: $[5, 7]$. There are no odd pairs, so the answer is $0$.
In the third sample, the buttons are: $[4]$. There are no pairs at all, so the answer is $0$.


It is the end of 2019 — the 17th of November, the Cooking Challenge day.
There are N$N$ players participating in this competition, numbered 1$1$ through N$N$. Initially, the skill level of each player is zero. There are also M$M$ challenges (numbered 1$1$ through M$M$). For each valid i$i$, the i$i$-th challenge has three parameters Li$L_i$, Ri$R_i$ and Xi$X_i$ with the following meaning: for each player between the Li$L_i$-th and Ri$R_i$-th inclusive, if this player participates in this challenge, their skill level increases by Xi$X_i$ (Xi$X_i$ does not have to be positive).
The organizers of the Cooking Challenge decided that the contest would be boring if they let the participants participate in the challenges directly, so they decided to use the compos.
There are Q$Q$ compos (numbered 1$1$ through Q$Q$). For each valid i$i$, the i$i$-th compo has two parameters Ai$A_i$ and Bi$B_i$, which means that it includes the challenges Ai,Ai+1,…,Bi$A_i, A_i+1, \ldots, B_i$.
Each participant has to select a subset of the compos (possibly empty or the set of all Q$Q$ compos) and participate in all challenges those compos include. A participant may not select the same compo twice, but may participate in the same challenge more than once if it is included in multiple chosen compos.
For each player, find the maximum skill level this player can reach if the compos are chosen optimally.

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of each test case contains three space-separated integers N$N$, M$M$ and Q$Q$.
- M$M$ lines follow. For each valid i$i$, the i$i$-th of these lines contains three space-separated integers Li$L_i$, Ri$R_i$ and Xi$X_i$.
- Q$Q$ more lines follow. For each valid i$i$, the i$i$-th of these lines contains two space-separated integers Ai$A_i$ and Bi$B_i$.

-----Output-----
For each test case, print a single line containing N$N$ space-separated integers. For each valid i$i$, the i$i$-th of these integers should denote the maximum skill level of the i$i$-th player.

-----Constraints-----
- 1≤T≤1,000$1 \le T \le 1,000$
- 1≤N≤100,000$1 \le N \le 100,000$
- 1≤M≤1,000$1 \le M \le 1,000$
- 1≤Q≤10,000$1 \le Q \le 10,000$
- 1≤Li≤Ri≤N$1 \le L_i \le R_i \le N$ for each valid i$i$
- 1≤Ai≤Bi≤M$1 \le A_i \le B_i \le M$ for each valid i$i$
- |Xi|≤1,000,000$|X_i| \le 1,000,000$ for each valid i$i$
- the sum of N$N$ over all test cases does not exceed 1,000,000$1,000,000$
- the sum of M$M$ over all test cases does not exceed 5,000$5,000$
- the sum of Q$Q$ over all test cases does not exceed 50,000$50,000$

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

-----Example Output-----
3 0 0 4 4

-----Explanation-----
Example case 1:
- The first player will select the 3$3$-rd compo.
- The second and third players will not select any compo.
- The fourth player will select the 1$1$-st, 2$2$-nd and 4$4$-th compos.
- The fifth player will select all the compos.


Chef has decided to start home delivery from his restaurant. He hopes that he will get a lot of orders for delivery, however there is a concern. He doesn't have enough work forces for all the deliveries.  For this he has came up with an idea - he will group together all those orders which have to be delivered in nearby areas.

In particular, he has identified certain bidirectional roads which he calls as fast roads. They are short and usually traffic free, so the fast travel is possible along these roads. His plan is that he will send orders to locations A and B together if and only if it is possible to travel between A and B using only fast roads. Your task is, given the configuration of fast roads, identify which orders are to be sent together.

-----Input-----
First line of input contains an integer T, the number of test cases. Then T test cases follow. First line of each test case contains two space separated integers N and M, denoting number of locations and the number of fast roads. Then M lines follow each containing two space separated integers A and B, denoting that there is a fast road between locations A and B. Assume that locations are indexed by numbers from 0 to N-1.

Next line contains an integer Q denoting the number of queries. Each of the next Q lines contain two integers X and Y. For each query you have to find out if orders meant for locations X and Y are to be sent together or not.

Note that there might be multiple fast roads between same pair of locations, also there might be a fast road that links a location to itself.

-----Output-----
For each test case print Q lines - one for each query. Output "YO" if the orders are to be
delivered together and "NO" otherwise (quotes for clarity).

-----Constraints-----
1 ≤ T ≤ 100
1 ≤ N ≤ 100
1 ≤ M ≤ 1000
0 ≤ A, B, X, Y ≤ N-1
1 ≤ Q ≤ 3000

-----Example-----
Input:
1
4 2
0 1
1 2
3
0 2
0 3
2 1

Output:
YO
NO
YO

-----Warning!-----
There are large input and output files in this problem. Make sure you use fast enough I/O methods.


The Chef is given an array of numbers and asked to find the first balance point of an array. A balance point is an index in the array N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no such balance point, print -1

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N denoting the number of weights on the array. The second line contains N space-separated integers A1, A2, ..., AN denoting the weights

-----Output-----
For each test case, output a single line containing the index of the first balance point. If no such index exists, output -1

-----Constraints-----
For Subtask 1:
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 10
- -1000 ≤ A1, A2, ..., AN ≤ 1000
For Subtask 1:
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 1000
- -10000 ≤ A1, A2, ..., AN ≤ 10000

-----Example-----
Input:
2
7
7 8 9 1 9 8 7
6
1 100 50 -51 1 1

Output:
3
1

-----Explanation-----
Example case 1. In the first case, at the midpoint of the array 1, the sum of the left side {7,8,9} is equal to the sum of the right side {9,8,7}
Example case 1. In the second case, at index 1, the sum of left side =1 is equal to the sum of the right side {50,-51,1,1}


Shivam is working on electric circuits. He requires some connecting wires. He needs to make a total of N connections and he has mentioned his wire length requirements for each connection in an integer sequence A. For buying wires, he need to decide the length of each wire piece, and he’ll get as many wire pieces of the chosen length each at unit cost (cost 1 per piece) but he can't get wires of different lengths. Also, he can't cut wire pieces to make new pieces of different (smaller) length(s).
But he can connect any number of wires together to form a new single wire piece whose length is the sum of lengths of the wires connected. So, Shivam needs to choose an integer length for buying wires. Shivam hates to waste anything, and he hates it even more if that thing is money.
Shivam is weak in mathematics and is asking you to help him in this situation. Help him decide the length of wires and total number of wires so as to minimize the total expenditure.
Note: You cannot make a connection which requires a wire piece of length X with a wire piece of length Y if X≠Y.
Input:
·        The first line of the input contains T = Number of Test cases
·        The first line of each test case contains an integer N
·        The second line contains N space separated integers A1, A2, …., AN.
Output:
For each test case print a single line containing two space separated integers, length of each wire and the corresponding minimum cost.
Constraints:
·       1 <= T <= 10
·       1 <= N <= 10^5
·        1 <= Ai <= 10^5, for each valid i
Sample Input:
1
3
2 4 8
Sample Output:
2 7


Consider the following algorithm
order(arr, i) {
if length(arr) <= 1 {
return arr
}
l = []
r = []
n = length(arr) - 1
for j in 0, 1, ..., n {
if ( (arr[j] modulo power(2,i+1))  < power(2,i) ) {
append arr[j] to l
}else{
append arr[j] to r
}
}
l = order(l, i + 1)
r = order(r, i + 1)
c = concatenate(l, r)
return c
}

Note that $concatenate(l, r)$ returns an array which is the array $l$, followed by the array $r$. Similarly $power(x,y)$ returns $x^y$.
Let $a$ be the array $a_0,a_1,a_2,a_3, \ldots,a_n$ where $a_j = j$ for each index $j$ and the last index $n = (2^p-1)$ for a fixed integer parameter $p$.  Given an integer $p$ and an index $idx$, your task is calculate the element at index $idx$ in the array returned by executing $order(a, 0)$.
For example, suppose $ p = 3$ and $idx = 3$.
- The initial array is $a = [0, 1, 2, 3, 4, 5, 6, 7]$.
- Executing $order(a, 0)$ first creates two new arrays $l == [0, 2, 4, 6]$ and $r == [1, 3, 5, 7]$.
- Next, $order(l, 1)$ and $order(r, 1)$ are executed.
- $order(l, 1)$, in turn, executes $order([0, 4], 2)$ and $order([2, 6], 2)$ which return $[0, 4]$ and $[2, 6]$, respectively. These are then concatenated, so $order(l, 1)$ returns $[0, 4, 2, 6]$.
- Similarly, $order(r, 1)$ returns $[1, 5, 3, 7]$.
- These two are concatenated as the final result, so the array returned by $order(a, 0)$ is $[0, 4, 2, 6, 1, 5, 3, 7]$.
So, if the input is $p = 3$, and $idx = 3$, the answer is $6$. If $p = 3$ and $idx = 7$, the answer should be $7$.

-----Input Format:-----
- The first line contains a single integer, $T$, which is the number of testcases. The description of each testcase follows.
- Each testcase is described by a single line with two integers: $p$ and $idx$, where $p$ is the parameter that determines the length of the array $a$ and $idx$ is the index at which you have to report the value in the output of $order(a, 0)$.

-----Output Format:-----
- You should print the answer in a new line for each testcase, which should be a single integer, the element at index $idx$ after executing $order(a, 0)$ for the array $a$ defined by the parameter $p$.

-----Constraints:-----
- $1 \leq T \leq 10$
- $1 \leq p \leq 50$
- $0 \leq idx \leq 2^p-1$

-----SUBTASKS:-----
- Subtask 1: 20% points : $1 \leq p \leq 20$
- Subtask 2: 80% points: Original constraints

-----Sample Input:-----
2
3 3
3 7

-----Sample Output:-----
6
7

-----Explanation:-----
Both the testcases have been explained in the problem statement.


You are given a string S containing only lowercase characters.
You can rearrange the string and you have to print minimum number of characters needed(can be 0) to make it palindrome.

-----Input:-----
- First line contain an interger T denoting number of testcases.
- First line of each testcase contains integer N, size of string.
- Second line of each testcase contains string S.

-----Output:-----
For each test case, print a single line containing one integer ― the minimum number of characters needed(can be 0) to make it palindrome.

-----Constraints-----
- $1 \leq T \leq 1000$
- $1 \leq N \leq 10^5$

-----Sample Input:-----
3
1
a
9
abbbcbddd
6
abcdef

-----Sample Output:-----
0
2
5

-----EXPLANATION:-----
- Example case 1: a is already a palindrome.
- Example case 2: abbddcddbba is palindrome by adding 2 more characters.
- Example case 3: abdefcfedba is palindrome by adding 5 more characters.


Write a program, which takes an integer N and if the number is less than 10 then display "Thanks for helping Chef!" otherwise print "-1".

-----Input-----

The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.

-----Output-----
For each test case, output the given string or -1 depending on conditions, in a new line.

-----Constraints-----
- 1 ≤ T ≤ 1000
- -20 ≤ N ≤ 20

-----Example-----
Input
3
1
12
-5
Output
Thanks for helping Chef!
-1
Thanks for helping Chef!

Thanks for helping Chef!
-1
Thanks for helping Chef!


Abhishek is fond of playing cricket very much. One morning, he is playing cricket with his friends. Abhishek  is a right-hand batsman

.He has to face  all types of balls either good or  bad. There are total 26 balls in the game and each ball is represented

by one of the following two ways:-
1. "g" denotes a good ball.
2. "b" denotes a bad  ball.
All 26 balls are represented by lower case letters (a,b,.....z).
Balls faced by Abhishek are represented as a string s, all the characters of which are lower case  i.e, within  26 above mentioned balls.
A substring s[l...r] (1≤l≤r≤|s|) of string s=s1s2...s|s| (where |s| is the length of string s) is string slsl+1...sr.
The substring s[l...r] is good, if among the letters slsl+1...sr, there are at most k bad ones (refer sample explanation ).
Your task is to find out the number of distinct good substrings for the given string s. Two substrings s[x...y] and s[p...q] are considered distinct if their contents are different, i.e. s[x...y]≠s[p...q].

-----Input Format-----
First Line contains an integer T, number of test cases. For each test case, first line contains a string - a sequence of balls faced by Abhishek.

And, next line contains a string of characters "g" and "b" of length 26 characters. If the ith character of this string equals "1", then the i-th English letter is good, otherwise it's bad. That is, the first character of this string corresponds to letter "a", the second one corresponds to letter "b" and so on.

And, the third line of the test case consists of a single integer k (0≤k≤|s|) — the maximum acceptable number of bad characters in a good substring.

-----Output Format -----
For each test case, print a single integer — the number of distinct good substrings of string s.

-----Constraints-----
- 1<=T<=1000
- 1<=|s|<=2000
- 0<=k<=|s|

-----Subtasks-----
Subtask 1 : 20 Points
- 1<=T<=10
- 1<=|s|<=20
- 0<=k<=|s|
Subtask 2 : 80 Points
Original Constraints
Sample Input
2
ababab
bgbbbbbbbbbbbbbbbbbbbbbbbb
1
acbacbacaa
bbbbbbbbbbbbbbbbbbbbbbbbbb
2
Sample Output
5
8

Explanation
In the first test case there are following good substrings: "a", "ab", "b", "ba", "bab".

In the second test case there are following good substrings: "a", "aa", "ac", "b", "ba", "c", "ca", "cb".


There are $5$ cities in the country.
The map of the country is given below.
The tour starts from the red city.

Each road is associated with a character.
Initially, there is an empty string.
Every time a road has been travelled the character associated gets appended to the string.
At the green city either the string can be printed or the tour can be continued.
In the problem, you are given a string tell whether it is possible to print the string while following the rules of the country?

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- Each testcase contains a single line of input, a string $ s  $. The string consists only of $0's$ and $1's$.

-----Output:-----
For each testcase, output "YES" or "NO" depending on the input.

-----Constraints-----
-
$1 \leq T \leq 10000$
-
$1 \leq length of each string \leq 10000$
-
$ 1 \leq Summation length \leq 10^5$

-----Sample Input:-----
1
100

-----Sample Output:-----
NO

-----EXPLANATION:-----


Gorodetskiy is a university student. He is really good at math and really likes solving engaging math problems. In the last exam, his professor gave him really hard math problems to solve, but Gorodetskiy could not solve them and failed the exam, so the professor told him: "These problems are a piece of cake, you should know them from school!" Here is one of the problems from the exam - you can decide if it really was an easy problem or not.
You are given a positive integer $M$. Let's call a positive integer $A$ an interesting number if there is at least one integer $B$ ($A \le B$) such that $A \cdot B$ is divisible by $M$ and $\frac{A \cdot B}{M} = A+B$.
Find all interesting numbers. Let's denote the number of such integers by $K$; it is guaranteed that $K \le 3*10^5$.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains a single integer $M$.

-----Output-----
For each test case:
- First, print a line containing a single integer $K$.
- Then, print $K$ lines. For each valid $i$, the $i$-th of these lines should contain a single integer ― the $i$-th interesting number in increasing order.

-----Constraints-----
- $1 \le T \le 10$
- $1 \le M \le 10^{14}$

-----Subtasks-----
Subtask #1 (20 points): $1 \le M \le 100$
Subtask #2 (20 points): $1 \le M \le 10^7$
Subtask #3 (60 points): original constraints

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

-----Example Output-----
2
4
6
5
7
8
9
10
12

-----Explanation-----
Example case 1: There are two interesting numbers, $4$ and $6$. For $A = 4$, we can choose $B = 12$ and for $A = 6$, we can choose $B = 6$.


You are given a sequence $A_1, A_2, \ldots, A_N$. For each $k$ ($1 \le k \le N$), let's define a function $f(k)$ in the following way:
- Consider a sequence $B_1, B_2, \ldots, B_N$, which is created by setting $A_k = 0$. Formally, $B_k = 0$ and $B_i = A_i$ for each valid $i \neq k$.
- $f(k)$ is the number of ways to split the sequence $B$ into two non-empty contiguous subsequences with equal sums.
Find the sum $S = f(1) + f(2) + \ldots + f(N)$.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $A_1, A_2, \ldots, A_N$.

-----Output-----
For each test case, print a single line containing one integer — the sum $S$.

-----Constraints-----
- $1 \le T \le 10$
- $2 \le N \le 2 \cdot 10^5$
- $1 \le |A_i| \le 10^9$ for each valid $i$

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

-----Example Output-----
6
2


Every college has a stud−max$stud-max$ buoy. JGEC$JGEC$ has its own Atul$Atul$ who loves to impress everyone with his smile. A presentation is going on at the auditorium where there are N$N$ rows of M$M$ chairs with people sitting on it. Everyone votes for Atul's presentation skills, but Atul is interested in knowing the maximum$maximum$ amount of vote that he receives either taking K$K$ people vertically$vertically$ or horizontally$horizontally$. Atul$Atul$, however, wants to finish up the presentation party soon, hence asks for your help so that he can wrap up things faster.

-----Input:-----
- First line will contain T$T$, number of test cases. Then the test cases follow.
- Each testcase contains of a single line of input, three integers N$N$, M$M$ and K$K$.
- N lines follow, where every line contains M numbers$numbers$ denoting the size of the sugar cube

-----Output:-----
For each test case, output in a single line the maximum votes Atul can get.

-----Constraints-----
- 1≤T≤$1 \leq T \leq $5
- 1≤N,M≤500$1 \leq N,M \leq 500$
- K≤min(N,M)$K \leq min(N,M)$
- 1≤numbers≤109$1 \leq numbers \leq 10^9$

-----Sample Input:-----
1
4 4 3
1 4 5 7
2 3 8 6
1 4 8 9
5 1 5 6

-----Sample Output:-----
22

-----EXPLANATION:-----
If Atul starts counting votes from (1,4), then he can take the 3 consecutive elements vertically downwards and those are 7,6 and 9 which is the maximum sum possible.


Kim has broken in to the base, but after walking in circles, perplexed by the unintelligible base design of the JSA, he has found himself in a large, empty, and pure white, room.
The room is a grid with H∗W$H*W$ cells, divided into H$H$ rows and W$W$ columns. The cell (i,j)$(i,j)$ is at height A[i][j]$A[i][j]$. Unfortunately, his advanced sense of smell has allowed him to sense a mercury leak, probably brought in by Jishnu to end his meddling. The mercury leak has a power (which determines what height the mercury can reach before dissipating into harmless quantities) and a source cell. It spreads from cells it has already reached to other cells in the four cardinal directions: north, south, east, and west. (That is, the mercury can spread up, down, right, or left in the grid, but not diagonally.) Mercury can only spread to a cell if the cell's height is strictly less than the power value.
Unfortunately, Kim does not exactly know the starting cell or the power value of the mercury leak. However, his impressive brain has determined that it must be one of Q$Q$ (power, starting cell) combinations. For each combination, he wants to find out how many cells are dangerous for him to go to: that is, how many cells will eventually be reached by the mercury. This will help him determine a suitable cell to stay in and slowly fix the leak from above.
Can you help Kim achieve this objective?
Note: If the starting cell's height is not less than the power level, the mercury immediately dissipates. So, in this case, output 0.

-----Input:-----
- First line will contain T$T$, number of testcases. Then the testcases follow.
- The first line in each testcase contains three integers, H$H$, W$W$, and Q$Q$.
- On the 2$2$nd to (H+1)$(H+1)$th lines of each testcase: The (i+1)$(i+1)$th line contains W$W$ space-separated integers, representing the heights of the cells on the i$i$th row of the grid.
- On the (H+2)$(H+2)$th to (H+Q+1)$(H+Q+1)$th lines of each testcase: The (i+H+1)$(i+H+1)$th line contains 3 space-separated integers, r[i]$r[i]$, c[i]$c[i]$, and p[i]$p[i]$, which represents a (power, starting cell) combination. For this specific combination, the mercury leak originates on the cell (r[i],c[i])$(r[i],c[i])$ and has power p[i]$p[i]$.

-----Output:-----
For each testcase, output Q$Q$ lines, with each line containing one integer. The i$i$th line should output the number of dangerous cells, given that the leak originated on cell (r[i],c[i])$(r[i],c[i])$ with power p[i]$p[i]$, as defined in the input. Read the sample and sample explanation for more details.

-----Constraints-----
- 1≤T≤2$1 \leq T \leq 2$
- 1≤H≤1000$1 \leq H \leq 1000$
- 1≤W≤1000$1 \leq W \leq 1000$
- 1≤Q≤2∗105$1 \leq Q \leq 2*10^5$
- 1≤r[i]≤H$1 \leq r[i] \leq H$ for all i$i$
- 1≤c[i]≤W$1 \leq c[i] \leq W$ for all i$i$
- 0≤A[i][j]≤109$0 \leq A[i][j] \leq 10^9$ for all (i,j)$(i,j)$
- 0≤p[i]≤109$0 \leq p[i] \leq 10^9$ for all i$i$.

-----Subtasks-----
- 10 points : A[i][j]=$A[i][j] =$ constant k$k$ for all (i,j)$(i,j)$ (the heights of all cells are equal).
- 20 points : H=1$H=1$, Q≤1000$Q \leq 1000$.
- 30 points: r[i]=$r[i] =$ constant x$x$, c[i]=$c[i] =$ constant y$y$ for all i$i$ (the starting cell is fixed).
- 40 points: No additional constraints.

-----Sample Input:-----
1
5 5 3
4 3 9 7 2
8 6 5 2 8
1 7 3 4 3
2 2 4 5 6
9 9 9 9 9
3 4 6
3 2 5
1 4 9

-----Sample Output:-----
10
0
19

-----EXPLANATION:-----
For the first query, the cell (3,4)$(3,4)$ has height 4. The mercury can reach the following cells: (2,3)$(2,3)$, (2,4)$(2,4)$, (3,1)$(3,1)$, (3,3)$(3,3)$, (3,4)$(3,4)$, (3,5)$(3,5)$, (4,1)$(4,1)$, (4,2)$(4,2)$, (4,3)$(4,3)$, (4,4)$(4,4)$, for a total of 10. Note that it cannot reach cell (4,5)$(4,5)$ because the height (6) is equal to the power value (6).
For the second query, the cell (3,2)$(3,2)$ has height 7. Since the power value of 5 is less than or equal to the height of 7, the mercury immediately dissipates and so it reaches 0 cells.
For the third query, the mercury can reach all cells except the bottom row and the cell (1,3)$(1,3)$.
Note that (x,y)$(x,y)$ means the cell on the x$x$-th row and y$y$-th column.


It's winter and taking a bath is a delicate matter. Chef has two buckets of water. The first bucket has $v_1$ volume of cold water at temperature $t_1$. The second has $v_2$ volume of hot water at temperature $t_2$. Chef wants to take a bath with at least $v_3$ volume of water which is at exactly $t_3$ temperature. To get the required amount of water, Chef can mix some water obtained from the first and second buckets.
Mixing $v_x$ volume of water at temperature $t_x$ with $v_y$ volume of water at temperature $t_y$ yields $v_x + v_y$ volume of water at temperature calculated as
vxtx+vytyvx+vyvxtx+vytyvx+vy\frac{v_x t_x + v_y t_y}{v_x + v_y}
Help Chef figure out if it is possible for him to take a bath with at least $v_3$ volume of water at temperature $t_3$.
Assume that Chef has no other source of water and that no heat is lost by the water in the buckets with time, so Chef cannot simply wait for the water to cool.

-----Input-----
- The first line contains $n$, the number of test cases. $n$ cases follow.
- Each testcase contains of a single line containing 6 integers $v_1, t_1, v_2, t_2, v_3, t_3$.

-----Output-----
- For each test case, print a single line containing "YES" if Chef can take a bath the way he wants and "NO" otherwise.

-----Constraints-----
- $1 \leq n \leq 10^5$
- $1 \leq v_1, v_2, v_3 \leq 10^6$
- $1 \leq t_1 < t_2 \leq 10^6$
- $1 \leq t_3 \leq 10^6$

-----Sample Input-----
3
5 10 5 20 8 15
5 10 5 20 1 30
5 10 5 20 5 20

-----Sample Output-----
YES
NO
YES

-----Explanation-----
- Case 1: Mixing all the water in both buckets yields 10 volume of water at temperature 15, which is more than the required 8.
- Case 2: It is not possible to get water at 30 temperature.
- Case 3: Chef can take a bath using only the water in the second bucket.


Everybody is worried about Rakesh as the boy does not have much knowledge about the real world. He can not go from one place to another on his own. It's high time he learned to explore the city. He is going to a relative's house situated on the other side of the city on his own. As this is his first time, he is carrying a GPS tracker of a special kind. The tracker continuously sends information to the family of Rakesh about his movement. The information is sent using the following four letters: U, D, R, and L. Those letters indicate the moves taken by Rakesh.

The city can be considered as a grid. Rakesh starts his journey from (0, 0) position of the grid. His relative's house is situated at (Rx, Ry). Rakesh can move in four directions: up, down, right, or left indicated by U, D, R, and L respectively.

Any position of the city with x ordinate negative or greater than M is considered as dangerous. Also, any position of the city with y ordinate negative or greater than N is considered as dangerous. You will be given the total sequence of Rakesh's movement. You need to determine if Rakesh ended up being at his relative's house, at a dangerous place, or at a random place in the city.

To make things clear,

-  U indicates a move that increases position along y-axis by 1
-  D indicates a move that decreases position along y-axis by 1
-  R indicates a move that increases position along x-axis by 1
-  L indicates a move that decreases position along x-axis by 1

Note that we are interested in the position of Rakesh at the end of his journey only. He may visit some dangerous place or his relative's house at some intermediate point but that won't affect the answer.

-----Input-----
- The first line of the input contains an integer T denoting the number of test cases. The description of each test case follows.

- The first line of each test case contains two integers M and N.
- The second line contains two integers Rx and Ry.
- The third line contains the length of Rakesh's move sequence.
- The next line contains the move sequence containing letters U, D, R, and L only with no space.

-----Output-----
For each test case, print "Case i: ", and then the answer, where i is the testcase number, 1-indexed. The answer should be any of the following three strings:
-  "REACHED" if Rakesh could reach his relative's house
-  "DANGER" if Rakesh ended up being in a dangerous place
-  "SOMEWHERE" if Rakesh ended up being in somewhere safe place in the city other than his relative's place
Don't print any quotation mark. Check the sample output.

-----Constraints-----

- 1 ≤ T ≤ 10
- 0 ≤ M, N ≤ 10000
- 0 ≤ Rx ≤  M
- 0 ≤ Ry ≤  N
- 0 ≤ Sum of the lengths of all sequences ≤ 10000

-----Example-----
Input:
2
20 20
4 5
13
LLUUUUURRRRRR
10 10
3 4
7
UDUDDRR

Output:
Case 1: REACHED
Case 2: DANGER


You have found $M$ different types of jewels in a mine and each type of jewel is present in an infinite number.
There are $N$ different boxes located at position $(1 ,2 ,3 ,...N)$.
Each box can collect jewels up to a certain number ( box at position $i$ have $i$ different partitions and each partition can collect at most one jewel of any type).
Boxes at odd positions are already fully filled with jewels while boxes at even positions are completely empty.
Print the total number of different arrangements possible so that all boxes can be fully filled.
As the answer can be very large you can print it by doing modulo with 1000000007(10^9+7).

-----Input:-----
- First line will contain $T$, number of testcases.
- Each testcase contains of a single line of input, two integers $N ,  M$.

-----Output:-----
For each testcase, Print the total number of different arrangement.

-----Constraints-----
- $1 \leq T \leq 20000$
- $1 \leq N \leq 1e9$
- $1 \leq M \leq 1e14$

-----Sample Input:-----
2
1 10
5 2

-----Sample Output:-----
1
64


Eugene loves sequences, especially arithmetic progressions. One day he was asked to solve a difficult problem.

If a sequence of numbers A1, A2, ... , AN form an arithmetic progression A, he was asked to calculate sum of F(Ai), for L ≤ i ≤ R.
F(X) is defined as:

If X < 10 then F(X) = X.

Else F(X) = F(sum_of_digits(X)).

Example:
F(1378) =
F(1+3+7+8) =
F(19) =
F(1 + 9) =
F(10) =
F(1+0) =
F(1) = 1

-----Input-----
- The first line of the input contains an integer T denoting the number of test cases.
- Each test case is described in one line containing four integers: A1 denoting the first element of the arithmetic progression A, D denoting the common difference between successive members of A, and L and R as described in the problem statement.

-----Output-----
- For each test case, output a single line containing one integer denoting sum of F(Ai).

-----Constraints-----
- 1 ≤ T ≤ 105
- 1 ≤ A1 ≤ 109
- 0 ≤ D ≤ 109
- 1 ≤ R ≤ 1018
- 1 ≤ L ≤ R

-----Subtasks-----
- Subtask 1:  0 ≤ D ≤ 100, 1 ≤ A1 ≤ 109, 1 ≤ R ≤ 100  - 15 points
- Subtask 2:  0 ≤ D ≤ 109, 1 ≤ A1 ≤ 109, 1 ≤ R ≤ 106  - 25 points
- Subtask 3: Original constraints - 60 points

-----Example-----
Input:
2
1 1 1 3
14 7 2 4

Output:
6
12

-----Explanation-----
Example case 1.
A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...}
A1 = 1
A2 = 2
A3 = 3
F(A1) = 1
F(A2) = 2
F(A3) = 3
1+2+3=6
Example case 2.
A = {14, 21, 28, 35, 42, 49, 56, 63, 70, 77,  ...}
A2 = 21
A3 = 28
A4 = 35
F(A2) = 3
F(A3) = 1
F(A4) = 8
3+1+8=12


There are players standing in a row each player has a digit written on their T-Shirt (multiple players can have the same number written on their T-Shirt).
You have to select a group of players, note that players in this group should be standing in $\textbf{consecutive fashion}$. For example second player of chosen group next to first player of chosen group, third player next to second and similarly last player next to second last player of chosen group. Basically You've to choose a contiguous group of players.
After choosing a group, players can be paired if they have the same T-Shirt number (one player can be present in at most one pair), finally the chosen group is called “good” if at most one player is left unmatched. Your task is to find the size of the maximum “good” group.
Formally, you are given a string $S=s_{1}s_{2}s_{3}...s_{i}...s_{n}$ where $s_{i}$ can be any digit character between $'0'$ and $'9'$ and $s_{i}$ denotes the number written on the T-Shirt of $i^{th}$ player. Find a value $length$ such that there exist pair of indices $(i,j)$ which denotes $S[i...j]$ is a “good” group where $i\geq1$ and $j\leq S.length$ and $i\leq j$ and $(j-i+1)=length$ and there exist no other pair $(i’,j’)$ such that $(j’-i’+1)>length$ and $S[i'...j']$ is a "good" group.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- $i^{th}$ testcase consist of a single line of input, a string $S$.

-----Output:-----
For each testcase, output in a single line maximum possible size of a "good" group.

-----Constraints-----
$\textbf{Subtask 1} (20 points)$
- $1 \leq T \leq 10$
- $S.length \leq 10^{3}$
$\textbf{Subtask 2} (80 points)$
- $1 \leq T \leq 10$
- $S.length \leq 10^{5}$

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

123343

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

-----EXPLANATION:-----
1$\textbf{$\underline{2 3 3}$}$43
Underlined group is a “good” group because the second player(number 2 on T-Shirt) is the only player who is left unmatched and third and fourth player can form a pair, no other group has length greater than 3 that are “good”. However note that we have other “good” group also 12$\textbf{$\underline{334}$}$3 but length is 3 which is same as our answer.

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

95665

-----Sample Output:-----
5

-----EXPLANATION:-----
$\textbf{$\underline{95665}$}$ is “good” group because first player is the only player who is left unmatched second and fifth player can form pair and third and fourth player also form pair.

-----Sample Input:-----
2

2323

1234567

-----Sample Output:-----
4

1

-----EXPLANATION:-----
For first test case
$\textbf{$\underline{2323}$}$ is a “good” group because there are no players who are left unmatched first and third player form pair and second and fourth player form pair.

For second test

Only length one "good" group is possible.


Chef loves to play with arrays by himself. Today, he has an array A consisting of N distinct integers. He wants to perform the following operation on his array A.

- Select a pair of adjacent integers and remove the larger one of these two. This decreases the array size by 1. Cost of this operation will be equal to the smaller of them.

Find out minimum sum of costs of operations needed to convert the array into a single element.

-----Input-----
First line of input contains a single integer T denoting the number of test cases. First line of each test case starts with an integer N denoting the size of the array A. Next line of input contains N space separated integers, where the ith integer denotes the value Ai.

-----Output-----
For each test case, print the minimum cost required for the transformation.

-----Constraints-----
- 1 ≤ T ≤ 10
- 2 ≤ N ≤ 50000
- 1 ≤ Ai ≤ 105

-----Subtasks-----
- Subtask 1 : 2 ≤ N ≤ 15 : 35 pts
- Subtask 2 : 2 ≤ N ≤ 100 : 25 pts
- Subtask 3 : 2 ≤ N ≤ 50000 : 40 pts

-----Example-----
Input
2
2
3 4
3
4 2 5

Output
3
4

-----Explanation-----Test 1 :  Chef will make only 1 move: pick up both the elements (that is, 3 and 4), remove the larger one (4), incurring a cost equal to the smaller one (3).


Our chef has been assigned a task to make a necklace of length N, from gold, diamond and platinum.There is single kind of gold, two types of diamond and three types of platinum available.
A necklace can be represented as strings of the form (G)∗(D1|D2)∗(P1|P2|P3)∗$ (G)*(D1|D2)*(P1|P2|P3)* $ where (x|y) means we can use x or y and ∗$ * $ means we can repeat the previous parenthesized expression 0 or more times.
Instead of making necklace he choose to count all such distinct necklaces possible for a given length N.

-----Input:-----
-The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
-Only line of every test case contains an integer N$N$ denoting the length of the necklace required.

-----Output:-----
For each test case, print the number of all such distinct necklaces, with given length. As the number can be really large, print it modulo  109+7$10^{9}+7$.

-----Constraints-----
- 1≤T≤10000$1 \leq T \leq 10000$
- 2≤N≤1000000000$2 \leq N \leq 1000000000$
- String S$S$ consists of only upper case english alphabets.

-----Subtasks-----
- 20 points : 1≤N≤5$1 \leq N \leq 5$
- 70 points : Original$Original$ Constraints$Constraints$

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

-----Sample Output:-----
6
25


Chef Zidane likes the number 9. He has a number N, and he wants to turn it into a multiple of 9. He cannot add or remove digits, and he can only change one digit at a time. The only allowed operation is to increment or decrement a digit by one, and doing this takes exactly one second. Note that he cannot increase a digit 9 or decrease a digit 0, and the resulting number must not contain any leading zeroes unless N has a single digit.

Chef Zidane wants to know the minimum amount of time (in seconds) needed to accomplish this. Please help him, before his kitchen gets overwhelmed with mist!

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Each test case consists of one line containing a single positive integer N.

-----Output-----
For each test case, output a single line containing the answer.

-----Constraints-----
- 1 ≤ T ≤ 105
- 1 ≤ N ≤ 10105
- N will not contain leading zeroes.
- Each test file is at most 3Mb in size.

-----Example-----
Input:4
1989
86236
90210
99999999999999999999999999999999999999988

Output:0
2
3
2

-----Explanation-----
Example case 1. 1989 is already divisible by 9, so no operations are needed to be performed.
Example case 2. 86236 can be turned into a multiple of 9 by incrementing the first and third digit (from the left), to get 96336. This takes 2 seconds.
Example case 3. 90210 can be turned into a multiple of 9 by decrementing the third digit twice and the fourth digit once, to get 90000. This takes 3 seconds.


The chef was playing with numbers and he found that natural number N can be obtained by sum various unique natural numbers, For challenging himself chef wrote one problem statement, which he decided to solve in future.
Problem statement: N can be obtained as the sum of Kth power of integers in multiple ways, find total number ways?
After that Cheffina came and read what chef wrote in the problem statement, for having some fun Cheffina made some changes in the problem statement as.
New problem statement: N can be obtained as the sum of Kth power of unique +ve integers in multiple ways, find total number ways?
But, the chef is now confused, how to solve a new problem statement, help the chef to solve this new problem statement.

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, two integers $N, K$.

-----Output:-----
For each test case, output in a single line answer to the problem statement.

-----Constraints-----
- $1 \leq T \leq 10$
- $1 \leq N \leq 1000$
- $1 \leq K \leq 6$

-----Sample Input:-----
2
4 1
38 2

-----Sample Output:-----
2
1

-----EXPLANATION:-----
For 1) 4 can be obtained by as [ 4^1 ], [1^1, 3^1], [2^1, 2^1]. (here ^ stands for power)
But here [2^1, 2^1] is not the valid way because it is not made up of unique +ve integers.
For 2) 38 can be obtained in the way which is [2^2, 3^2, 5^2] = 4 + 9 + 25


Get excited, folks, because it is time for the final match of Codechef Premier League (CPL)!
Mike and Tracy also want to watch the grand finale, but unfortunately, they could not get tickets to the match. However, Mike is not someone who gives up so easily — he has a plan to watch the match.
The field where the match is played is surrounded by a wall with height $K$. Outside, there are $N$ boxes (numbered $1$ through $N$). For each valid $i$, the $i$-th box has a height $H_i$.
Mike wants to take some boxes and stack them on top of each other to build two towers. The height of each tower is the sum of heights of all the boxes that form it. Of course, no box may be in both towers. The height of each tower should be at least $K$. Then Mike can climb on top of one tower and Tracy on top of the other, and they can watch the match uninterrupted!
While Mike is busy stacking the boxes, Tracy would like to know the smallest number of boxes required to build two towers such that each of them has height at least $K$, or at least that it is impossible to build such towers. Can you help Tracy?

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains two space-separated integers $N$ and $K$.
- The second line contains $N$ space-separated integers $H_1, H_2, \ldots, H_N$.

-----Output-----
For each test case, print a single line containing one integer — the smallest number of boxes required to build two towers, or $-1$ if it is impossible.

-----Constraints-----
- $1 \leq T \leq 5$
- $1 \leq N, K \leq 4,000$
- $1 \leq H_i \leq 10^5$ for each valid $i$

-----Subtasks-----
Subtask #1 (30 points):
- $1 \leq N, K \leq 100$
- $1 \leq H_i \leq 100$ for each valid $i$
Subtask #2 (70 points): original constraints

-----Example Input-----
2
8 38
7 8 19 7 8 7 10 20
4 5
2 10 4 9

-----Example Output-----
7
2

-----Explanation-----
Example case 1: The first tower can be built with boxes $8 + 10 + 20 = 38$ and the second tower with boxes $7 + 7 + 8 + 19 = 41$. In this case, the box with height $7$ is left unused.
Example case 2: We only need the box with height $10$ for one tower and the box with height $9$ for the other tower.


Chef likes all arrays equally. But he likes some arrays more equally than others. In particular, he loves Rainbow Arrays.
An array is Rainbow if it has the following structure:
- First a1 elements equal 1.
- Next a2 elements equal 2.
- Next a3 elements equal 3.
- Next a4 elements equal 4.
- Next a5 elements equal 5.
- Next a6 elements equal 6.
- Next a7 elements equal 7.
- Next a6 elements equal 6.
- Next a5 elements equal 5.
- Next a4 elements equal 4.
- Next a3 elements equal 3.
- Next a2 elements equal 2.
- Next a1 elements equal 1.
- ai can be any non-zero positive integer.
- There are no other elements in array.

Help Chef in finding out if the given array is a Rainbow Array or not.

-----Input-----
- The first line of the input contains an integer T denoting the number of test cases.
- The first line of each test case contains an integer N, denoting the number of elements in the given array.
- The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of array.

-----Output-----
- For each test case, output a line containing "yes" or "no" (without quotes) corresponding to the case if the array is rainbow array or not.

-----Constraints-----
- 1 ≤ T ≤ 100
- 7 ≤ N ≤ 100
- 1 ≤ Ai ≤ 10

-----Subtasks-----
- Subtask 1 (100 points) : Original constraints

-----Example-----
Input
3
19
1 2 3 4 4 5 6 6 6 7 6 6 6 5 4 4 3 2 1
14
1 2 3 4 5 6 7 6 5 4 3 2 1 1
13
1 2 3 4 5 6 8 6 5 4 3 2 1

Output
yes
no
no

-----Explanation-----
The first example satisfies all the conditions.
The second example has 1 element of value 1 at the beginning and 2 elements of value 1 at the end.
The third one has no elements with value 7 after elements with value 6.


You are given a string $s$. And you have a function $f(x)$ defined as:
f(x) = 1, if $x$ is a vowel
f(x) = 0, if $x$ is a constant

Your task is to apply the above function on all the characters in the string s and convert
the obtained binary string in decimal number $M$.
Since the number $M$ can be very large, compute it modulo $10^9+7$.

-----Input:-----
- The first line of the input contains a single integer $T$ i.e the no. of test cases.
- Each test line contains one String $s$ composed of lowercase English alphabet letters.

-----Output:-----
For each case, print a single line containing one integer $M$ modulo $10^9 + 7$.

-----Constraints-----
- $1 ≤ T ≤ 50$
- $|s|≤10^5$

-----Subtasks-----
- 20 points : $|s|≤30$
- 80 points : $ \text{original constraints}$

-----Sample Input:-----
1
hello

-----Sample Output:-----
9


Chef and his friend Miron were getting bored and decided to play a game.
Miron thinks of a sequence of  N  integers (A1, A2, …., AN) and gives Chef a matrix B, where Bi,j = |Ai - Aj|. He further tells Chef that A1 = 0. The game is for Chef to guess the sequence that Miron thought of.
But Miron is an adversarial player. Every time Chef tries to guess the sequence, he makes a change to the matrix. He makes such a change Q times. Each time, he replaces an entry in some row and the corresponding column with a new one leaving Chef to guess the sequence after each change.
Chef needs a friend to help him against such an adversarial player. Can you be that friend and help Chef find a suitable sequence A for the initial matrix B and also after each change Miron makes?
Note that if several answers exist, then print the lexicographically smallest answer. Further, the numbers in the sequence can be negative.

-----Input-----

The first line contains two space-separated integers N, Q. Each of the N subsequent lines contains N space-separated integers, denoting the matrix B.

Q queries follow. Each query has two lines. The first line of each query contains an integer p, denoting the number of row and column that is changed. The second line of each query contains N space-separated integers F1, F2, F3, ... FN, denoting the new values to the corresponding cells of the matrix (you should make the following assignments Bi,p = Bp,i = Fi for all valid i).

-----Output-----
Print Q + 1 lines which contain N space-separated integers, Miron's initial array and Miron's array after each query.

-----Constraints-----
- 3 ≤ N ≤  1000
- 1 ≤ Q ≤  1000
- 0 ≤ Bi,j ≤  5000
- 1 ≤ p ≤  n
- 0 ≤ Fi ≤  5000
- it's guaranteed there's always an answer

-----Example-----
Input:
3 2
0 1 2
1 0 1
2 1 0
1
0 4 3
2
4 0 7
Output:
0 -1 -2
0 -4 -3
0 -4 3

-----Explanation-----
Example case 1. Initially, sequence {0, 1, 2} is also suitable, but {0, -1, -2} is lexicografically smaller.


Batman is about to face Superman so he decides to prepare for the battle by upgrading his Batmobile. He manufactures multiple duplicates of his standard Batmobile each tweaked in a different way such that the maximum speed of each is never less than that of the standard model.
After carrying out this process, he wishes to know how many of his prototypes are faster than his standard Batmobile?

-----Input-----
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follow:
- The first line of each test case contains a single integer N denoting the number of copies of the standard Batmobile.
- The second line contains a sequence of N+1 space-separated integers, S0 to SN, sorted in non-decreasing order separated by space. S0 is the maximum speed of the standard Batmobile. S1 to SN denote the maximum speeds of the prototypes.

-----Output-----
- For each test case, output a single line containing an integer denoting the answer.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 1000
- 1 ≤ Si ≤ 109

-----Example-----
Input:
2
4
1 2 3 4 5
5
1 10 100 1000 10000 100000

Output:
4
5


After the death of their mother, Alphonse and Edward now live with Pinako and Winry.

Pinako is worried about their obsession with Alchemy, and that they don't give attention to their studies.
So to improve their mathematical solving ability, every day she gives a mathematical problem to solve. They can go out to practice Alchemy only after they have solved the problem.
Help them by solving the given problem, so that they can go early today for their Alchemy practice.
Given an array A$A$ of N$N$ non-negative integers and two integers K$K$ and M$M$. Find the number of subsequences of array A$A$ of length K$K$ which satisfies the following property:

Suppose the subsequence is S=S1S2…SK$S = S_1S_2 \ldots S_K$, then for all i$i$ such that 1≤i≤K$1 \leq i \leq K$,
Si%M=i%M S_i \% M = i \% M
should hold true, where Si$S_i$ denotes the i$i$-th element of the subsequence, using 1-based indexing.
As the number of subsequences may be very large, output the answer modulo 1000000007$1000000007$.
PS: We also proposed the idea of making a look-alike clone through alchemy and keeping it in front of the study table. But it seems impossible to convince Edward to make a clone of his exact same height, and not taller than him. So solving the problem for him was a better choice.

-----Input:-----
- The first line contains T$T$, the number of test cases. Then the test cases follow.
- For every test case, the first line contains N$N$, K$K$ and M$M$.
- For every test case, the second line contains N$N$ integers Ai$A_{i}$ ( 1≤i≤N$1 \leq i \leq N$).

-----Output:-----
For every test case, output in a single line an integer denoting the number of valid subsequences modulo 109+7$10^9+7$

-----Constraints-----
- 1≤T≤100$1 \leq T \leq 100$
- 1≤N≤104$1 \leq N \leq 10^{4}$
- 1≤K≤N$1 \leq K \leq N$
- ⌈K100⌉≤M≤100×K$\lceil \frac{K}{100}\rceil \leq M \leq  100\times K$
- 0≤Ai≤109$0 \leq A_{i} \leq 10^{9}$

-----Sample Input:-----
1
12 4 3
4 5 6 7 1 4 6 9 0 0 10 2

-----Sample Output:-----
8

-----Explanation:-----
The subsequences of length 4$4$, satisfying the given criteria are [4,5,6,7]$[4, 5, 6, 7]$, [4,5,6,10]$[4, 5, 6, 10]$, [4,5,6,10]$[4, 5, 6, 10]$, [4,5,6,1]$[4, 5, 6, 1]$, [4,5,9,10]$[4, 5, 9, 10]$ ,[4,5,6,4]$[4, 5, 6, 4]$ , [4,5,0,10]$[4, 5, 0, 10]$ and [4,5,0,10]$[4, 5, 0, 10]$. This accounts for a total of 8$8$ valid subsequences.
Let us take one subsequence and see why it satisfies the given property. Consider [4,5,9,10]$[4, 5, 9, 10]$.
- S1%M=4%3=1=1%3=1%M$ S_1 \% M = 4 \% 3 = 1 = 1 \% 3 = 1 \% M $
- S2%M=5%3=2=2%3=2%M$ S_2 \% M = 5 \% 3 = 2 = 2 \% 3 = 2 \% M $
- S3%M=9%3=0=3%3=3%M$ S_3 \% M = 9 \% 3 = 0 = 3 \% 3 = 3 \% M $
- S4%M=10%3=1=4%3=4%M$ S_4 \% M = 10 \% 3 = 1 = 4 \% 3 = 4 \% M $
All the valid i$i$ satisfy the condition, and hence this is a valid subsequence.


Bohan loves milk tea so much and he drinks one cup of milk tea every day. The local shop sells milk tea in two sizes: a Medium cup for $3 and a Large cup for $4. For every cup of milk tea purchased Bohan receives a promotional stamp. Bohan may redeem 6 stamps for a free drink of milk tea regardless of the size. No stamp will be given for a free drink.

Determine the amount of money Bohan have spent on milk tea, given a sequence of milk tea sizes he got in the past a few days. Assume Bohan had no stamps in the beginning and he always redeemed the stamps for the next drink once he had collected 6 stamps.

-----Input-----
The input begins with the number of test cases T.
Each test case has a single line of letters. The i-th letter is either 'M' or 'L' denoting a Medium cup or a Large cup of milk tea Bohan got on the i-th day.

-----Output-----
For each case, output the amount of money in dollars Bohan have spent on milk tea.

-----Constraints-----
- T ≤ 100
- 1 ≤  length of each sequence ≤ 100

-----Example-----
Input:
3
MLM
MMLLMMLL
MMMMMMML

Output:
10
24
22

-----Explanation-----
Example 1: Bohan didn't redeem any stamps.
Example 2: Bohan redeemed 6 stamps for the Large cup of milk tea on the 7th day.
Example 3: Bohan redeemed 6 stamps for the Medium cup of milk tea on the 7th day.


A despotic king decided that his kingdom needed to be rid of corruption and disparity. He called his prime minister and ordered that all corrupt citizens be put to death. Moreover, he wanted this done quickly.
The wily prime minister realised that investigating every citizen to decide who was corrupt and who was not was rather difficult. So he decided on the following plan: He ordered all the citizens to appear in the court one by one and declare their wealth.
The king does not sit in the court all the time (he has other important business to attend to - for instance, meet dignitaries from neighbouring kingdoms, spend time with his family …) Whenever the king walks into the court, the prime minister pulls out the richest man who has appeared before the court so far and is still alive and beheads him for being corrupt. Since the rich are more likely to be corrupt, he hopes to get rid of most of the corrupt and the king is happy as he sees his policy being implemented enthusiastically.
Suppose the wealth of the citizens trooping into the court is
1376518911241376518911241\; 3\; 7\; 6\; 5\; 18\;  9\; 11\;  2\; 4
and the king walked in three times: the first time after the first four persons have seen the minister, the second time after the first five persons have seen the minister and, finally after the first nine persons have seen the minister.
At the king's first visit the richest person to have met the minister has wealth $7$ and he would be beheaded. At the second visit, the wealth of the richest person who has met the minister and is still alive has wealth $6$ and so he would be beheaded. At the third visit the richest person to have met the minister who is still alive has wealth $18$ and so he would be beheaded.
You may assume that the input is such that whenever the king walks in, it is always possible to behead someone.
Your aim is to write a program that will enable the prime minister to identify the richest man to have met the minister and who is still alive quickly. You may assume that no two citizens have the same wealth.

-----Input:-----
The first line of the input consists of two numbers $N$ and $M$, where $N$ is the number of citizens in the kingdom and M is the number of visits to the court by the king.
The next $N+M$ lines describe the order in which the $N$ citizens' appearances are interleaved with the $M$ visits by the king. A citizen's visit is denoted by a positive integer, signifying his wealth. You may assume that no two citizens have the same wealth. A visit by the king is denoted by $-1$.

-----Output:-----
Your output should consist of $M$ lines, where the $i^{th}$ line contains the wealth of the citizen who is beheaded at the $i^{th}$ visit of the king.

-----Constraints:-----
- $1 \leq M \leq 10000$.
- $1 \leq N \leq 100000$.
- You may assume that in $50 \%$ of the inputs $1 \leq M \leq 1000$ and $1 \leq N \leq 8000$.

-----Sample Input-----
10 3
1
3
7
6
-1
5
-1
18
9
11
2
-1
4

-----Sample Output-----
7
6
18


Gru wants to distribute $N$ bananas to $K$ minions on his birthday.
Gru does not like to just give everyone the same number of bananas, so instead, he wants to distribute bananas in such a way that each minion gets a $distinct$ amount of bananas. That is, no two minions should get the same number of bananas.
Gru also loves $gcd$. The higher the $gcd$, the happier Gru and the minions get. So help Gru in distributing the bananas in such a way that each Minion gets a distinct amount of bananas and gcd of this distribution is highest possible. Output this maximum gcd. If such a distribution is not possible output $-1$.
Note: You have to distribute $all$ $N$ bananas.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- Each testcase consists of a single line of input, which has two integers: $N, K$.

-----Output:-----
For each testcase, output in a single line the maximum gcd or -1.

-----Constraints-----
- $1 \leq T \leq 100$
- $1 \leq N, K \leq 10^9$

-----Sample Input:-----
1
6 3

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

-----EXPLANATION:-----
The only possible distribution is $[1, 2, 3]$. So the answer is 1.


Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence ― what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want to simply give this sequence to Chef. Instead, she decided to give Chef a sequence $B_1, B_2, \ldots, B_N$, where $B_i = \bigvee_{j=1}^i A_j$ for each valid $i$ and $\bigvee$ denotes the bitwise OR operation. Chef can try to generate a sequence $A$ from $B$, but there could be more than one such possible sequence.
Now, Alice is wondering how many sequences $A$ correspond to the given sequence $B$. Since this number could be very large, compute it modulo $10^9 + 7$. Note that it is not guaranteed that the given sequence $B$ was generated from some sequence $A$.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $B_1, B_2, \ldots, B_N$.

-----Output-----
For each test case, print a single line containing one integer ― the number of possible sequences $A$ modulo $10^9 + 7$.

-----Constraints-----
- $1 \le T \le 25$
- $1 \le N \le 5 \cdot 10^4$
- $0 \le B_i < 2^{30}$ for each valid $i$

-----Example Input-----
2
2
2 3
4
2 6 7 7

-----Example Output-----
2
64

-----Explanation-----
Example case 1: There are two possible options for $A$: $(2, 1)$ and $(2, 3)$.


Vasya learned about integer subtraction in school. He is still not very good at it, so he is only able to subtract any single digit number from any other number (which is not necessarily single digit).
For practice, Vasya chose a positive integer n$n$ and wrote it on the first line in his notepad. After that, on the second line he wrote the result of subtraction of the first digit of n$n$ from itself. For example, if n=968$n = 968$, then the second line would contain 968−9=959$968 - 9 = 959$, while with n=5$n = 5$ the second number would be 5−5=0$5 - 5 = 0$. If the second number was still positive, then Vasya would write the result of the same operation on the following line, and so on. For example, if n=91$n = 91$, then the sequence of numbers Vasya would write starts as follows: 91,82,74,67,61,55,50,…$91, 82, 74, 67, 61, 55, 50, \ldots$. One can see that any such sequence eventually terminates with the number 0$0$.
Since then, Vasya lost his notepad. However, he remembered the total number k$k$ of integers he wrote down (including the first number n$n$ and the final number 0$0$). What was the largest possible value of n$n$ Vasya could have started with?

-----Input:-----
The first line contains T$T$ , number of test cases per file.
The only line in each testcase contains a single integer k−$k-$ the total number of integers in Vasya's notepad (2≤k≤1012$2 \leq k \leq 10^{12}$).

-----Output:-----
Print a single integer−$-$ the largest possible value of the starting number n$n$. It is guaranteed that at least one such number n$n$ exists, and the largest possible value is finite.

-----Constraints-----
- 1≤T≤34$1 \leq  T \leq 34 $
- 2≤k≤1012$2 \leq k \leq 10^{12}$

-----Sample Input-----
3
2
3
100

-----Sample Output:-----
9
10
170


Chef's love for Fibonacci numbers helps him to design following interesting problem.
He defines a function F for an array S as follows:

where
- Si denotes a non-empty subset of multiset S.
- sum(Si) denotes the sum of all element of multiset Si.
- Fibonacci(x) denotes the xth Fibonacci number.
Given an array A consisting of N elements. Chef asked you to process following two types of queries on this array accurately and efficiently.
- C X Y: Change the value of Xth element of array to Y i.e AX = Y.
- Q L R: Compute function F over the subarray defined by the elements of array A in the range L to R, both inclusive.

Please see the Note section if you need details regarding Fibonacci function.

-----Input-----
First line of input contains 2 space separated integer N and M denoting the size of array A and the number of queries to be performed. Next line of input contains N space separated integers denoting the elements of array A. Each of next M lines of input contains a query having one of the mentioned two types.

-----Output-----
For each query of type Q, output the value of function F for the given range of array A.

-----Constraints-----
- 1 ≤ N, M ≤ 105
- 1 ≤ Ai, Y ≤ 109
- 1 ≤ L, R, X ≤ N
-  type = {'C', 'Q'}

-----Subtasks-----
- Subtask 1 (20 points) : 1 ≤ N, M ≤ 1000, 1 ≤ Ai, Y ≤ 106, type = { 'Q' }
- Subtask 2 (20 points) : 1 ≤ N, M ≤ 50000, 1 ≤ Ai, Y ≤ 109, type = { 'C', Q' }
- Subtask 3 (30 points) : 1 ≤ N, M ≤ 105, 1 ≤ Ai, Y ≤ 109, type = { 'Q' }
- Subtask 4 (30 points) : 1 ≤ N, M ≤ 105, 1 ≤ Ai, Y ≤ 109, type = { 'C', Q' }

-----Example-----
Input
3 5
1 2 3
Q 1 2
Q 2 3
C 1 2
Q 1 2
Q 1 3

Output
4
8
5
30

-----Explanation:-----
- Q1 : F = Fibonacci(1) + Fibonacci(2) + Fibonacci(1+2) = 4 % 1000000007 = 4
- Q2 : F = Fibonacci(2) + Fibonacci(3) + Fibonacci(2+3) = 8 % 1000000007 = 8
- Q3 : A = {2, 2, 3}
- Q4 : F = Fibonacci(2) + Fibonacci(2) + Fibonacci(2+2) = 5 % 1000000007 = 5
- Q5 : F = Fibonacci(2) + Fibonacci(2) + Fibonacci(3) + Fibonacci(2+2) + Fibonacci(2+3) + Fibonacci(2+3) + Fibonacci(2+2+3) = 30 % 1000000007 = 30

-----Note-----
FibonacciK denotes the Kth Fibonacci number. Fibonacci series is defined as follows:
- For 1 ≤ K ≤ 2, FibonacciK = 1
- Otherwise, FibonacciK = FibonacciK-1 + FibonacciK-2
Please check this link for more details about Fibonacci numbers.


There is a task in Among Us in which $N$ temperature scale with unique readings are given and you have to make all of them equal. In one second you can choose an odd number and add or subtract that number in any one temperature value. Find minimum time (in seconds) required to complete the task.
$Note$: Equal value may or may not belong to array.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- First line of each testcase contains single integer $N$, the number of temperature scales
- Next line contain $A_i$ for $1 \leq i \leq N$, reading of temperature scales

-----Output:-----
For each testcase, output a single line the time (in seconds) required to complete the task.

-----Constraints-----
- $1 \leq T \leq 10^3$
- $1 \leq N \leq 10^3$
- $0 \leq A_i \leq 10^9$

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

5

1 2 3 4 5

4

5 2 3 8

2

50 53

-----Sample Output:-----
5

4

1

-----EXPLANATION:-----
- In the $2^{nd}$ test case we need $2$ seconds to change $2$ to $8$ , $1$ second to change $3$ and $5$ to $8$ . So total time required is $2+1+1=4$ seconds.


The students of Codechef Middle School are visiting an amusement park. The children want to go on a ride, however, there is a minimum height requirement of $X$ cm. Determine if the children are eligible to go on the ride.
Print "Yes" if they are eligible, "No" otherwise.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- Each testcase contains of a single line of input, two integers $H$ which is a child's height in cm and $X$ which is the minimum permissible height.

-----Output:-----
For each testcase, output in a single line $"Yes"$ or $"No"$. You cannot give your answer as "YeS", "YES", "yes" or any other variation.

-----Constraints-----
- $1 \leq T \leq 10^4$
- $50 \leq H \leq 200$
- $50 \leq X \leq 200$

-----Sample Input:-----
2
120 100
90 100

-----Sample Output:-----
Yes
No

-----EXPLANATION:-----
The first child has height more than minimum permissible height, so he can go on the ride while the other person cannot!


Chef Hari has got a new obsession now: he has started playing chess (read about it here) and he is liking this game very much. Since Hari has spent several months playing chess with his friends, he has now decided to take part in some chess tournament in Cheftown.

There are currently two tournaments going on in Cheftown and each tournament has its own entry fee. Due to this economical restriction and his budget, Hari can take part in only one tournament.

The entry fee for first tournament is F1 units of money. The structure of tournament is as follows: first there will be group matches and then there will be finals. If Hari reaches in finals and wins it, he'll get R1 units of money. If after reaching in finals, Hari loses, he'll get R2 units of money. If Hari fails to reach in finals, he'll get nothing. The probability of reaching in finals of first tournament for Hari is p1 and probability of winning in finals after reaching is p2.

The entry fee for second tournament is F2 units of money. The structure of tournament is as follows: first there will be group matches and then there will be finals. If Hari reaches in finals, he'll immediately get R3 units of money, otherwise he'll get nothing. If after reaching in finals, Hari wins, he'll get R4 units of money. The probability of reaching in finals of second tournament for Hari is p3 and probability of winning in finals after reaching is p4.

Now, Hari wants to maximise his profit. He wants to know which tournament he should participate in such that his expected profit is maximised. Help Hari in deciding this.

Note:
In the tournaments of Cheftown, the game never ends with a draw. So, either Hari wins a game, or he loses.

-----Input-----

First line of the input contains T, the number of test cases. The description of each test case is as following:

First line of each test case contains 6 integers F1, F2, R1, R2, R3 and R4.

Next line of each test case contains 4 floating point numbers p1, p2, p3 and p4.
Each number has exactly 2 digits after decimal point.

-----Output-----

For each test case, output a single line having "FIRST" if expected profit of first tournament is maximum or "SECOND" if expected profit of second tournament is maximum or "BOTH" if expected profits of both the tournaments is exactly same.

-----Constraints-----
- 1 ≤ T ≤ 100
- 1 ≤ F1, F2, R1, R2, R3, R4 ≤ 100
- 0.00 ≤ p1, p2, p3, p4 ≤ 1.00

-----Subtasks-----
Subtask#1: 30 points
- p1 = p3 and p2 = p4

Subtask#2: 70 points
- All usual constraints.

-----Example-----
Input:
2
30 50 70 10 40 30
0.25 0.10 0.30 0.05
50 36 80 38 65 32
0.55 0.12 0.33 0.54

Output:
FIRST
SECOND

-----Explanation-----

In the first case, the expected profit for first tournament is -26.00 and expected profit for second tournament is -37.55. So, first tournament has better expected profit.

In the second case, the expected profit for first tournament is -26.328 and expected profit for second tournament is -8.8476. So, second tournament has better expected profit.


Chef works as a cook in a restaurant. Each morning, he has to drive down a straight road with length K$K$ to reach the restaurant from his home. Let's describe this road using a coordinate X$X$; the position of Chef's home is X=0$X = 0$ and the position of the restaurant is X=K$X = K$.
The road has exactly two lanes (numbered 1$1$ and 2$2$), but there are N$N$ obstacles (numbered 1$1$ through N$N$) on it. For each valid i$i$, the i$i$-th obstacle blocks the lane Li$L_i$ at the position X=Xi$X = X_i$ and does not block the other lane.
When driving, Chef cannot pass through an obstacle. He can switch lanes in zero time at any integer X$X$-coordinate which does not coincide with the X$X$-coordinate of any obstacle. However, whenever he switches lanes, he cannot switch again until driving for at least D$D$ units of distance, and he can travel only in the direction of increasing X$X$. Chef can start driving in any lane he wants. He can not switch lanes at non-integer  X$X$-coordinate.
Sometimes, it is impossible to reach the restaurant without stopping at an obstacle. Find the maximum possible distance Chef can travel before he has to reach an obstacle which is in the same lane as him. If he can avoid all obstacles and reach the restaurant, the answer is K$K$.

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of each test case contains three space-separated integers N$N$, K$K$ and D$D$.
- The second line contains N$N$ space-separated integers X1,X2,…,XN$X_1, X_2, \ldots, X_N$.
- The third line contains N$N$ space-separated integers L1,L2,…,LN$L_1, L_2, \ldots, L_N$.

-----Output-----
For each test case, print a single line containing one integer ― the maximum distance Chef can travel.

-----Constraints-----
- 1≤T≤1,000$1 \le T \le 1,000$
- 1≤N≤105$1 \le N \le 10^5$
- 2≤K≤109$2 \le K \le 10^9$
- 1≤D≤109$1 \le D \le 10^9$
- 1≤Xi≤K−1$1 \le X_i \le K-1$ for each valid i$i$
- Xi<Xi+1$X_i < X_{i+1}$ for each valid i$i$
- 1≤Li≤2$1 \le L_i \le 2$ for each valid i$i$
- the sum of N$N$ over all test cases does not exceed 106$10^6$

-----Subtasks-----
Subtask #1 (100 points): original constraints

-----Example Input-----
4
2 10 20
4 7
1 2
4 15 20
4 6 9 13
1 2 2 1
5 10 1
1 3 5 7 9
1 2 1 2 1
2 10 2
4 5
1 2

-----Example Output-----
10
13
10
5

-----Explanation-----
Example case 1: Chef can start in lane 2$2$ and switch to lane 1$1$ at the position X=6$X = 6$, then continue until reaching the restaurant.
Example case 2: Chef can start in lane 2$2$ and switch to lane 1$1$ at X=5$X = 5$. However, he cannot avoid the obstacle at X=13$X = 13$, because he has not driven for at least 20$20$ units since the last switch.
Example case 3: Chef should start in lane 2$2$ and then switch lanes at the positions X=2$X=2$, X=4$X=4$, X=6$X=6$ and X=8$X=8$. This way, he can reach the restaurant.
Example case 4: Chef can start in lane 2$2$ but he cannot escape the second obstacle at X$X$=5 since the first obstacle at X$X$=4 doesn't give enough space for Chef to switch lanes.