You are given a prime number $$$n$$$, and an array of $$$n$$$ integers $$$b_1,b_2,\ldots, b_n$$$, where $$$0 \leq b_i < n$$$ for each $$$1 \le i \leq n$$$.You have to find a matrix $$$a$$$ of size $$$n \times n$$$ such that all of the following requirements hold:  $$$0 \le a_{i,j} < n$$$ for all $$$1 \le i, j \le n$$$.  $$$a_{r_1, c_1} + a_{r_2, c_2} \not\equiv a_{r_1, c_2} + a_{r_2, c_1} \pmod n$$$ for all positive integers $$$r_1$$$, $$$r_2$$$, $$$c_1$$$, and $$$c_2$$$ such that $$$1 \le r_1 < r_2 \le n$$$ and $$$1 \le c_1 < c_2 \le n$$$. $$$a_{i,i} = b_i$$$ for all $$$1 \le i \leq n$$$. Here $$$x \not \equiv y \pmod m$$$ denotes that $$$x$$$ and $$$y$$$ give different remainders when divided by $$$m$$$.If there are multiple solutions, output any. It can be shown that such a matrix always exists under the given constraints.

The first line contains a single positive integer $$$n$$$ ($$$2 \le n < 350$$$).  The second line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$0 \le b_i < n$$$) — the required values on the main diagonal of the matrix. It is guaranteed that $$$n$$$ is prime.

Print $$$n$$$ lines. On the $$$i$$$-th line, print $$$n$$$ integers $$$a_{i, 1}, a_{i, 2}, \ldots, a_{i, n}$$$, each separated with a space. If there are multiple solutions, output any.

NoteIn the first example, the answer is valid because all entries are non-negative integers less than $$$n = 2$$$, and $$$a_{1,1}+a_{2,2} \not\equiv a_{1,2}+a_{2,1} \pmod 2$$$ (because $$$a_{1,1}+a_{2,2} = 0 + 0 \equiv 0 \pmod 2$$$ and $$$a_{1,2}+a_{2,1} = 1 + 0 \equiv 1 \pmod 2 $$$). Moreover, the values on the main diagonals are equal to $$$0,0$$$ as required.In the second example, the answer is correct because all entries are non-negative integers less than $$$n = 3$$$, and the second condition is satisfied for all quadruplets $$$(r_1, r_2, c_1, c_2)$$$. For example:   When $$$r_1=1$$$, $$$r_2=2$$$, $$$c_1=1$$$ and $$$c_2=2$$$, $$$a_{1,1}+a_{2,2} \not\equiv a_{1,2}+a_{2,1} \pmod 3$$$ because $$$a_{1,1}+a_{2,2} = 1 + 1 \equiv 2 \pmod 3$$$ and $$$a_{1,2}+a_{2,1} = 2 + 1 \equiv 0 \pmod 3 $$$.  When $$$r_1=2$$$, $$$r_2=3$$$, $$$c_1=1$$$, and $$$c_2=3$$$, $$$a_{2,1}+a_{3,3} \not\equiv a_{2,3}+a_{3,1} \pmod 3$$$ because $$$a_{2,1}+a_{3,3} = 1 + 1 \equiv 2 \pmod 3$$$ and $$$a_{2,3}+a_{3,1} = 0 + 1 \equiv 1 \pmod 3 $$$.  Moreover, the values on the main diagonal are equal to $$$1,1,1$$$ as required.


Your working week consists of $$$n$$$ days numbered from $$$1$$$ to $$$n$$$, after day $$$n$$$ goes day $$$1$$$ again. And $$$3$$$ of them are days off. One of the days off is the last day, day $$$n$$$. You have to decide when the other two are.Choosing days off, you pursue two goals:   No two days should go one after the other. Note that you can't make day $$$1$$$ a day off because it follows day $$$n$$$.  Working segments framed by days off should be as dissimilar as possible in duration. More specifically, if the segments are of size $$$l_1$$$, $$$l_2$$$, and $$$l_3$$$ days long, you want to maximize $$$\min(|l_1 - l_2|, |l_2 - l_3|, |l_3 - l_1|)$$$. Output the maximum value of $$$\min(|l_1 - l_2|, |l_2 - l_3|, |l_3 - l_1|)$$$ that can be obtained.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The description of test cases follows. The only line of each test case contains the integer $$$n$$$ ($$$6 \le n \le 10^9$$$).

For each test case, output one integer — the maximum possible obtained value.

NoteIn the image below you can see the example solutions for the first two test cases. Chosen days off are shown in purple. Working segments are underlined in green.In test case $$$1$$$, the only options for days off are days $$$2$$$, $$$3$$$, and $$$4$$$ (because $$$1$$$ and $$$5$$$ are next to day $$$n$$$). So the only way to place them without selecting neighboring days is to choose days $$$2$$$ and $$$4$$$. Thus, $$$l_1 = l_2 = l_3 = 1$$$, and the answer $$$\min(|l_1 - l_2|, |l_2 - l_3|, |l_3 - l_1|) = 0$$$.   For test case $$$2$$$, one possible way to choose days off is shown. The working segments have the lengths of $$$2$$$, $$$1$$$, and $$$4$$$ days. So the minimum difference is $$$1 = \min(1, 3, 2) = \min(|2 - 1|, |1 - 4|, |4 - 2|)$$$. It can be shown that there is no way to make it larger.


There are $$$n$$$ pieces of tangerine peel, the $$$i$$$-th of them has size $$$a_i$$$. In one step it is possible to divide one piece of size $$$x$$$ into two pieces of positive integer sizes $$$y$$$ and $$$z$$$ so that $$$y + z = x$$$.You want that for each pair of pieces, their sizes differ strictly less than twice. In other words, there should not be two pieces of size $$$x$$$ and $$$y$$$, such that $$$2x \le y$$$. What is the minimum possible number of steps needed to satisfy the condition?

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of test cases follows. The first line of each test case contains the integer $$$n$$$ ($$$1 \le n \le 100$$$). Then one line follows, containing $$$n$$$ integers $$$a_1 \le a_2 \le \ldots \le a_n$$$ ($$$1 \le a_i \le 10^7$$$).

For each test case, output a single line containing the minimum number of steps.

NoteIn the first test case, we initially have a piece of size $$$1$$$, so all final pieces must have size $$$1$$$. The total number of steps is: $$$0 + 1 + 2 + 3 + 4 = 10$$$.In the second test case, we have just one piece, so we don't need to do anything, and the answer is $$$0$$$ steps.In the third test case, one of the possible cut options is: $$$600,\ 900,\ (600 | 700),\ (1000 | 1000),\ (1000 | 1000 | 550)$$$. You can see this option in the picture below. The maximum piece has size $$$1000$$$, and it is less than $$$2$$$ times bigger than the minimum piece of size $$$550$$$. $$$4$$$ steps are done. We can show that it is the minimum possible number of steps.


You are given an integer array $$$a$$$ of length $$$n$$$. Does there exist an array $$$b$$$ consisting of $$$n+1$$$ positive integers such that $$$a_i=\gcd (b_i,b_{i+1})$$$ for all $$$i$$$ ($$$1 \leq i \leq n$$$)? Note that $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10^5$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ space-separated integers $$$a_1,a_2,\ldots,a_n$$$ representing the array $$$a$$$ ($$$1 \leq a_i \leq 10^4$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output "YES" if such $$$b$$$ exists, otherwise output "NO". You can print each letter in any case (upper or lower).

NoteIn the first test case, we can take $$$b=[343,343]$$$.In the second test case, one possibility for $$$b$$$ is $$$b=[12,8,6]$$$.In the third test case, it can be proved that there does not exist any array $$$b$$$ that fulfills all the conditions.


You are given two arrays $$$a$$$ and $$$b$$$ of $$$n$$$ elements, each element is either $$$0$$$ or $$$1$$$.You can make operations of $$$2$$$ kinds.   Pick an index $$$i$$$ and change $$$a_i$$$ to $$$1-a_i$$$.  Rearrange the array $$$a$$$ however you want. Find the minimum number of operations required to make $$$a$$$ equal to $$$b$$$.

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 100$$$) — the length of the arrays $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ space-separated integers $$$a_1,a_2,\ldots,a_n$$$ ($$$a_i$$$ is $$$0$$$ or $$$1$$$), representing the array $$$a$$$. The third line of each test case contains $$$n$$$ space-separated integers $$$b_1,b_2,\ldots,b_n$$$ ($$$b_i$$$ is $$$0$$$ or $$$1$$$), representing the array $$$b$$$.

For each test case, print the minimum number of operations required to make $$$a$$$ equal to $$$b$$$.

NoteIn the first case, we need only one operation: change $$$a_1$$$ to $$$1-a_i$$$. Now $$$a = [0, 0]$$$ which is equal to $$$b$$$.In the second case, the optimal way is to rearrange $$$a$$$ to get the array $$$[0, 1, 11$$$. Now $$$a = [0, 0, 1]$$$ which is equal to $$$b$$$.In the second case, one of optimal ways would be to first change $$$a_3$$$ to $$$1 - a_3$$$, then rearrange $$$a$$$.In the third case, no operation is needed.In the fourth case, the optimal way is to rearrange $$$a$$$ to get the array $$$[0, 1, 1, 0]$$$.


There was a string $$$s$$$ which was supposed to be encrypted. For this reason, all $$$26$$$ lowercase English letters were arranged in a circle in some order, afterwards, each letter in $$$s$$$ was replaced with the one that follows in clockwise order, in that way the string $$$t$$$ was obtained. You are given a string $$$t$$$. Determine the lexicographically smallest string $$$s$$$ that could be a prototype of the given string $$$t$$$.A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ of the same length if and only if:   in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter, that appears earlier in the alphabet than the corresponding letter in $$$b$$$.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 3 \cdot 10^4$$$) — the number of test cases. The description of test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the string $$$t$$$. The next line contains the string $$$t$$$ of the length $$$n$$$, containing lowercase English letters. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

For each test case, output a single line containing the lexicographically smallest string $$$s$$$ which could be a prototype of $$$t$$$.

NoteIn the first test case, we couldn't have the string "a", since the letter a would transit to itself. Lexicographically the second string "b" is suitable as an answer.In the second test case, the string "aa" is not suitable, since a would transit to itself. "ab" is not suitable, since the circle would be closed with $$$2$$$ letters, but it must contain all $$$26$$$. The next string "ac" is suitable.Below you can see the schemes for the first three test cases. The non-involved letters are skipped, they can be arbitrary placed in the gaps.

5

1

a

2

ba

10

codeforces

26

abcdefghijklmnopqrstuvwxyz

26

abcdefghijklmnopqrstuvwxzy

b
ac
abcdebfadg
bcdefghijklmnopqrstuvwxyza
bcdefghijklmnopqrstuvwxyaz


You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total.A feature for three cards is called good if it is the same for these cards or pairwise distinct. Three cards are called a set if all $$$k$$$ features are good for them.For example, the cards $$$(0, 0, 0)$$$, $$$(0, 2, 1)$$$, and $$$(0, 1, 2)$$$ form a set, but the cards $$$(0, 2, 2)$$$, $$$(2, 1, 2)$$$, and $$$(1, 2, 0)$$$ do not, as, for example, the last feature is not good.A group of five cards is called a meta-set, if there is strictly more than one set among them. How many meta-sets there are among given $$$n$$$ distinct cards?

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^3$$$, $$$1 \le k \le 20$$$) — the number of cards on a table and the number of card features. The description of the cards follows in the next $$$n$$$ lines. Each line describing a card contains $$$k$$$ integers $$$c_{i, 1}, c_{i, 2}, \ldots, c_{i, k}$$$ ($$$0 \le c_{i, j} \le 2$$$) — card features. It is guaranteed that all cards are distinct.

Output one integer — the number of meta-sets.

NoteLet's draw the cards indicating the first four features. The first feature will indicate the number of objects on a card: $$$1$$$, $$$2$$$, $$$3$$$. The second one is the color: red, green, purple. The third is the shape: oval, diamond, squiggle. The fourth is filling: open, striped, solid.You can see the first three tests below. For the first two tests, the meta-sets are highlighted.In the first test, the only meta-set is the five cards $$$(0000,\ 0001,\ 0002,\ 0010,\ 0020)$$$. The sets in it are the triples $$$(0000,\ 0001,\ 0002)$$$ and $$$(0000,\ 0010,\ 0020)$$$. Also, a set is the triple $$$(0100,\ 1000,\ 2200)$$$ which does not belong to any meta-set.   In the second test, the following groups of five cards are meta-sets: $$$(0000,\ 0001,\ 0002,\ 0010,\ 0020)$$$, $$$(0000,\ 0001,\ 0002,\ 0100,\ 0200)$$$, $$$(0000,\ 0010,\ 0020,\ 0100,\ 0200)$$$.   In there third test, there are $$$54$$$ meta-sets.


There are two currencies: pebbles and beads. Initially you have $$$a$$$ pebbles, $$$b$$$ beads.There are $$$n$$$ days, each day you can exchange one currency for another at some exchange rate.On day $$$i$$$, you can exchange $$$-p_i \leq x \leq p_i$$$ pebbles for $$$-q_i \leq y \leq q_i$$$ beads or vice versa. It's allowed not to perform an exchange at all. Meanwhile, if you perform an exchange, the proportion $$$x \cdot q_i = -y \cdot p_i$$$ must be fulfilled. Fractional exchanges are allowed.You can perform no more than one such exchange in one day. The numbers of pebbles and beads you have must always remain non-negative.Please solve the following $$$n$$$ problems independently: for each day $$$i$$$, output the maximum number of pebbles that you can have at the end of day $$$i$$$ if you perform exchanges optimally.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of test cases. The description of test cases follows. The first line of each test case contains three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 300\,000$$$, $$$0 \le a, b \le 10^9$$$) — the number of days and the initial number of pebbles and beads respectively. The second line of each test case contains $$$n$$$ integers: $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le 10^9$$$). The third line of each test case contains $$$n$$$ integers: $$$q_1, q_2, \ldots, q_n$$$ ($$$1 \le q_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$300\,000$$$.

Output $$$n$$$ numbers — the maximum number of pebbles at the end of each day. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{\left|a - b\right|}{\max(1, \left|b\right|)} \le 10^{-6}$$$.

NoteIn the image below you can see the solutions for the first two test cases. In each line there is an optimal sequence of actions for each day.In the first test case, the optimal strategy for the first day is to do no action at all, as we can only decrease the number of pebbles. The optimal strategy for the second day is at first to exchange $$$1$$$ pebble for $$$2$$$ beads, which is a correct exchange, since $$$1 \cdot 4 = 2 \cdot 2$$$, and then to exchange $$$2$$$ beads for $$$3$$$ pebbles.


This is the easy version of this problem. In this version, we do not have queries. Note that we have multiple test cases in this version. You can make hacks only if both versions of the problem are solved.An array $$$b$$$ of length $$$m$$$ is good if for all $$$i$$$ the $$$i$$$-th element is greater than or equal to $$$i$$$. In other words, $$$b$$$ is good if and only if $$$b_i \geq i$$$ for all $$$i$$$ ($$$1 \leq i \leq m$$$).You are given an array $$$a$$$ consisting of $$$n$$$ positive integers. Find the number of pairs of indices $$$(l, r)$$$, where $$$1 \le l \le r \le n$$$, such that the array $$$[a_l, a_{l+1}, \ldots, a_r]$$$ is good.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 2 \cdot 10^5$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$), the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ space-separated integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \leq a_i \leq n$$$), representing the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print the number of suitable pairs of indices.

NoteIn the first test case, all subarrays of $$$a$$$ are good, so all pairs are suitable.In the second test case, the pairs $$$(1, 1)$$$, $$$(2, 2)$$$, and $$$(3, 3)$$$ are suitable. For example, when $$$(l, r) = (1, 2)$$$, the array $$$b=[1,1]$$$ is not good because $$$b_2 < 2$$$.


There are $$$n$$$ houses in your city arranged on an axis at points $$$h_1, h_2, \ldots, h_n$$$. You want to build a new house for yourself and consider two options where to place it: points $$$p_1$$$ and $$$p_2$$$.As you like visiting friends, you have calculated in advance the distances from both options to all existing houses. More formally, you have calculated two arrays $$$d_1$$$, $$$d_2$$$: $$$d_{i, j} = \left|p_i - h_j\right|$$$, where $$$|x|$$$ defines the absolute value of $$$x$$$.After a long time of inactivity you have forgotten the locations of the houses $$$h$$$ and the options $$$p_1$$$, $$$p_2$$$. But your diary still keeps two arrays — $$$d_1$$$, $$$d_2$$$, whose authenticity you doubt. Also, the values inside each array could be shuffled, so values at the same positions of $$$d_1$$$ and $$$d_2$$$ may correspond to different houses. Pay attention, that values from one array could not get to another, in other words, all values in the array $$$d_1$$$ correspond the distances from $$$p_1$$$ to the houses, and in the array $$$d_2$$$  — from $$$p_2$$$ to the houses.Also pay attention, that the locations of the houses $$$h_i$$$ and the considered options $$$p_j$$$ could match. For example, the next locations are correct: $$$h = \{1, 0, 3, 3\}$$$, $$$p = \{1, 1\}$$$, that could correspond to already shuffled $$$d_1 = \{0, 2, 1, 2\}$$$, $$$d_2 = \{2, 2, 1, 0\}$$$.Check whether there are locations of houses $$$h$$$ and considered points $$$p_1$$$, $$$p_2$$$, for which the founded arrays of distances would be correct. If it is possible, find appropriate locations of houses and considered options.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of test cases. The description of test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the length of arrays $$$d_1$$$, $$$d_2$$$. The next two lines contain $$$n$$$ integers each: arrays $$$d_1$$$ and $$$d_2$$$ ($$$0 \le d_{i, j} \le 10^9$$$) respectively. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^3$$$.

For each test case, output a single line "NO" if there is no answer. Otherwise output three lines. The first line must contain "YES". In the second line, print $$$n$$$ integers $$$h_1, h_2, \ldots, h_n$$$. In the third line print two integers $$$p_1$$$, $$$p_2$$$. It must be satisfied that $$$0 \le h_i, p_1, p_2 \le 2 \cdot 10^9$$$. We can show that if there is an answer, then there is one satisfying these constraints. If there are several answers, output any of them.

NoteIn the image below you can see the sample solutions. Planned houses are shown in bright colours: pink and purple. Existing houses are dim. In test case $$$1$$$, the first planned house is located at point $$$0$$$, the second at point $$$10$$$. The existing house is located at point $$$5$$$ and is at a distance of $$$5$$$ from both planned houses.   It can be shown that there is no answer for test case $$$2$$$.   In test case $$$3$$$, the planned houses are located at points $$$33$$$ and $$$69$$$.   Note that in test case $$$4$$$, both plans are located at point $$$1$$$, where one of the existing houses is located at the same time. It is a correct placement.


This is the hard version of this problem. In this version, we have queries. Note that we do not have multiple test cases in this version. You can make hacks only if both versions of the problem are solved.An array $$$b$$$ of length $$$m$$$ is good if for all $$$i$$$ the $$$i$$$-th element is greater than or equal to $$$i$$$. In other words, $$$b$$$ is good if and only if $$$b_i \geq i$$$ for all $$$i$$$ ($$$1 \leq i \leq m$$$).You are given an array $$$a$$$ consisting of $$$n$$$ positive integers, and you are asked $$$q$$$ queries. In each query, you are given two integers $$$p$$$ and $$$x$$$ ($$$1 \leq p,x \leq n$$$). You have to do $$$a_p := x$$$ (assign $$$x$$$ to $$$a_p$$$). In the updated array, find the number of pairs of indices $$$(l, r)$$$, where $$$1 \le l \le r \le n$$$, such that the array $$$[a_l, a_{l+1}, \ldots, a_r]$$$ is good.Note that all queries are independent, which means after each query, the initial array $$$a$$$ is restored.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$). The third line contains an integer $$$q$$$ ($$$1 \leq q \leq 2 \cdot 10^5$$$) — the number of queries. Each of the next $$$q$$$ lines contains two integers $$$p_j$$$ and $$$x_j$$$ ($$$1 \leq p_j, x_j \leq n$$$) – the description of the $$$j$$$-th query.

For each query, print the number of suitable pairs of indices after making the change.


While working at DTL, Ela is very aware of her physical and mental health. She started to practice various sports, such as Archery, Yoga, and Football.Since she started engaging in sports activities, Ela switches to trying a new sport on days she considers being "Luxury" days. She counts the days since she started these activities, in which the day she starts is numbered as day $$$1$$$. A "Luxury" day is the day in which the number of this day is a luxurious number. An integer $$$x$$$ is called a luxurious number if it is divisible by $$${\lfloor \sqrt{x} \rfloor}$$$.Here $$$\lfloor r \rfloor$$$ denotes the "floor" of a real number $$$r$$$. In other words, it's the largest integer not greater than $$$r$$$.For example: $$$8$$$, $$$56$$$, $$$100$$$ are luxurious numbers, since $$$8$$$ is divisible by $$$\lfloor \sqrt{8} \rfloor = \lfloor 2.8284 \rfloor = 2$$$, $$$56$$$ is divisible $$$\lfloor \sqrt{56} \rfloor = \lfloor 7.4833 \rfloor = 7$$$, and $$$100$$$ is divisible by $$$\lfloor \sqrt{100} \rfloor = \lfloor 10 \rfloor = 10$$$, respectively. On the other hand $$$5$$$, $$$40$$$ are not, since $$$5$$$ are not divisible by $$$\lfloor \sqrt{5} \rfloor = \lfloor 2.2361 \rfloor = 2$$$, and $$$40$$$ are not divisible by $$$\lfloor \sqrt{40} \rfloor = \lfloor 6.3246 \rfloor = 6$$$.Being a friend of Ela, you want to engage in these fitness activities with her to keep her and yourself accompanied (and have fun together, of course). Between day $$$l$$$ and day $$$r$$$, you want to know how many times she changes the activities.

Each test contains multiple test cases. The first line has the number of test cases $$$t$$$ ($$$1 \le t \le 10\ 000$$$). The description of the test cases follows. The only line of each test case contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le 10^{18}$$$) — the intervals at which you want to know how many times Ela changes her sports.

For each test case, output an integer that denotes the answer.

NoteIn the first test case, $$$5$$$ luxury numbers in range $$$[8, 19]$$$ are: $$$8, 9, 12, 15, 16$$$.


You're given an array consisting of $$$n$$$ integers. You have to perform $$$n$$$ turns.Initially your score is $$$0$$$.On the $$$i$$$-th turn, you are allowed to leave the array as it is or swap any one pair of $$$2$$$ adjacent elements in the array and change exactly one of them to $$$0$$$(and leave the value of other element unchanged) after swapping. In either case(whether you swap or not), after this you add $$$a_i$$$ to your score. What's the maximum possible score you can get?

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 500$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^6$$$).

Print a single integer — the maximum possible score.

NoteIn the first example, to get the maximum score we do as follows. Do nothing on the first turn, add $$$3$$$ to the score. Swap the first and the second elements and turn $$$1$$$ to $$$0$$$ on the second turn, and add $$$3$$$ to the score. The final score is $$$6$$$.


Ela likes to go hiking a lot. She loves nature and exploring the various creatures it offers. One day, she saw a strange type of ant, with a cannibalistic feature. More specifically, an ant would eat any ants that it sees which is smaller than it.Curious about this feature from a new creature, Ela ain't furious. She conducts a long, non-dubious, sentimental experiment.She puts $$$n$$$ cannibalistic ants in a line on a long wooden stick. Initially, the ants have the same weight of $$$1$$$. The distance between any two consecutive ants is the same. The distance between the first ant in the line to the left end and the last ant in the line to the right end is also the same as the distance between the ants. Each ant starts moving towards the left-end or the right-end randomly and equiprobably, at the same constant pace throughout the experiment. Two ants will crash if they are standing next to each other in the line and moving in opposite directions, and ants will change direction immediately when they reach the end of the stick. Ela can't determine the moving direction of each ant, but she understands very well their behavior when crashes happen.  If a crash happens between two ants of different weights, the heavier one will eat the lighter one, and gain the weight of the lighter one. After that, the heavier and will continue walking in the same direction. In other words, if the heavier one has weight $$$x$$$ and walking to the right, the lighter one has weight $$$y$$$ and walking to the left ($$$x > y$$$), then after the crash, the lighter one will diminish, and the heavier one will have weight $$$x + y$$$ and continue walking to the right.  If a crash happens between two ants with the same weight, the one walking to the left end of the stick will eat the one walking to the right, and then continue walking in the same direction. In other words, if one ant of weight $$$x$$$ walking to the left, crashes with another ant of weight $$$x$$$ walking to the right, the one walking to the right will disappear, and the one walking to the left will have to weight $$$2x$$$ and continue walking to the left. Please, check the example in the "Note" section, which will demonstrate the ants' behavior as above.We can prove that after a definite amount of time, there will be only one last ant standing. Initially, each ant can randomly and equiprobably move to the left or the right, which generates $$$2^n$$$ different cases of initial movements for the whole pack. For each position in the line, calculate the probability that the ant begins in that position and survives. Output it modulo $$$10^9 + 7$$$.Formally, let $$$M = 10^9 + 7$$$. It can be shown that the answer can be expressed as an irreducible fraction $$$\frac{p}{q}$$$, where $$$p$$$ and $$$q$$$ are integers and $$$q \not \equiv 0 \pmod{M}$$$. Output the integer equal to $$$p \cdot q^{-1} \bmod M$$$. In other words, output such an integer $$$x$$$ that $$$0 \le x < M$$$ and $$$x \cdot q \equiv p \pmod{M}$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). The description of the test cases follows. The only line of each test contains an integer $$$n$$$ ($$$1 \le n \le 10^6$$$) — the number of ants in the experiment. It is guaranteed that the sum of $$$n$$$ in all tests will not exceed $$$10^6$$$.

For each test, print $$$n$$$ lines. $$$i$$$-th line contains a single number that denotes the survival probability of the $$$i$$$-th ant in the line modulo $$$10^9 + 7$$$.

NoteHere is the example of $$$6$$$ ants moving on the branch. An ant's movement will be denoted by either a character $$$L$$$ or $$$R$$$. Initially, the pack of ants on the branch will move as $$$RLRRLR$$$. Here's how the behavior of the pack demonstrated:  Initially, the ants are positioned as above.  After a while, the ant with index $$$2$$$ (walking to the left) will crash with the ant with index $$$1$$$ (walking to the right). The two ants have the same weight, therefore, ant $$$2$$$ will eat ant $$$1$$$ and gain its weight to $$$2$$$. The same thing happens with ant $$$5$$$ and ant $$$4$$$.The ant $$$6$$$ will walk to the end of the stick, therefore changing its direction.  After that, the ant with index $$$5$$$ will crash with the ant with index $$$3$$$. Since ant $$$5$$$ is more heavy (weight=$$$2$$$) than ant $$$3$$$ (weight=$$$1$$$), ant $$$5$$$ will eat ant $$$3$$$ and gain its weight to $$$3$$$.Ant $$$2$$$ will walk to the end of the stick, therefore changing its direction.  After that, the ant with index $$$5$$$ will crash with the ant with index $$$2$$$. Since ant $$$5$$$ is more heavy (weight=$$$3$$$) than ant $$$2$$$ (weight=$$$2$$$), ant $$$5$$$ will eat ant $$$2$$$ and gain its weight to $$$5$$$.  Lastly, after ant $$$5$$$ walk to the end of the branch and changes its direction, ant $$$5$$$ will eat ant $$$6$$$ and be the last ant standing.


Ela loves reading a lot, just like her new co-workers in DTL! On her first day after becoming an engineer in DTL, she is challenged by a co-worker to sort a heap of books into different compartments on the shelf.$$$n$$$ books must be split into $$$k$$$ compartments on the bookshelf ($$$n$$$ is divisible by $$$k$$$). Each book is represented by a lowercase Latin letter from 'a' to 'y' inclusively, which is the beginning letter in the title of the book.Ela must stack exactly $$$\frac{n}{k}$$$ books in each compartment. After the books are stacked, for each compartment indexed from $$$1$$$ to $$$k$$$, she takes the minimum excluded (MEX) letter of the multiset of letters formed by letters representing all books in that compartment, then combines the resulting letters into a string. The first letter of the resulting string is the MEX letter of the multiset of letters formed by the first compartment, the second letter of the resulting string is the MEX letter of the multiset of letters formed by the second compartment, ... and so on. Please note, under the constraint of this problem, MEX letter can always be determined for any multiset found in this problem because 'z' is not used.What is the lexicographically greatest resulting string possible that Ela can create?A string $$$a$$$ is lexicographically greater than a string $$$b$$$ if and only if one of the following holds:  $$$b$$$ is a prefix of $$$a$$$, but $$$b \ne a$$$;  in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter that appears later in the alphabet than the corresponding letter in $$$b$$$. The minimum excluded (MEX) letter of a multiset of letters is the letter that appears earliest in the alphabet and is not contained in the multiset. For example, if a multiset of letters contains $$$7$$$ letters 'b', 'a', 'b', 'c', 'e', 'c', 'f' respectively, then the MEX letter of this compartment is 'd', because 'd' is not included in the multiset, and all letters comes before 'd' in the alphabet, namely 'a', 'b' and 'c', are included in the multiset.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 200$$$; $$$1 \le k \le n$$$). It is guaranteed that $$$n$$$ is divisible by $$$k$$$. The second line of each test case contains a string of $$$n$$$ lowercase Latin letters from 'a' to 'y' inclusively. Each letter represents the starting letter of the title of a book in the initial heap. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$.

For each test case, output a string of $$$k$$$ letters which is the most optimal string that Ela can find.

NoteIn the first test case, the books can be divided into $$$3$$$ compartments as below:  the first compartment contains the books with indices $$$1, 2, 3, 7$$$: $$$multiset_1 = \{$$$'c', 'a', 'b', 'd'$$$\}$$$ $$$\rightarrow$$$ $$$MEX(multiset_1) =$$$ 'e'  the second compartment contains the books with indices $$$4, 5, 6, 9$$$ : $$$multiset_2 = \{$$$'c', 'c', 'a', 'b'$$$\}$$$ $$$\rightarrow$$$ $$$MEX(multiset_2) =$$$ 'd'  the third compartment contains the remaining books $$$8, 10, 11, 12$$$ : $$$multiset_3 = \{$$$ 'a', 'a', 'a', 'c'$$$\}$$$ $$$\rightarrow$$$ $$$MEX(multiset_3) =$$$ 'b' Therefore, the answer is 'edb'. It can be proven that there is no way that Ela can arrange the books so that it results in a lexicographically greater string.

5

12 3

cabccadabaac

12 6

cabccadabaac

12 12

cabccadabaac

25 1

abcdefghijklmnopqrstuvwxy

10 5

bcdxedbcfg


Everool has a binary string $$$s$$$ of length $$$2n$$$. Note that a binary string is a string consisting of only characters $$$0$$$ and $$$1$$$. He wants to partition $$$s$$$ into two disjoint equal subsequences. He needs your help to do it.You are allowed to do the following operation exactly once.   You can choose any subsequence (possibly empty) of $$$s$$$ and rotate it right by one position. In other words, you can select a sequence of indices $$$b_1, b_2, \ldots, b_m$$$, where $$$1 \le b_1 < b_2 < \ldots < b_m \le 2n$$$. After that you simultaneously set $$$$$$s_{b_1} := s_{b_m},$$$$$$ $$$$$$s_{b_2} := s_{b_1},$$$$$$ $$$$$$\ldots,$$$$$$ $$$$$$s_{b_m} := s_{b_{m-1}}.$$$$$$Can you partition $$$s$$$ into two disjoint equal subsequences after performing the allowed operation exactly once?A partition of $$$s$$$ into two disjoint equal subsequences $$$s^p$$$ and $$$s^q$$$ is two increasing arrays of indices $$$p_1, p_2, \ldots, p_n$$$ and $$$q_1, q_2, \ldots, q_n$$$, such that each integer from $$$1$$$ to $$$2n$$$ is encountered in either $$$p$$$ or $$$q$$$ exactly once, $$$s^p = s_{p_1} s_{p_2} \ldots s_{p_n}$$$, $$$s^q = s_{q_1} s_{q_2} \ldots s_{q_n}$$$, and $$$s^p = s^q$$$.If it is not possible to partition after performing any kind of operation, report $$$-1$$$. If it is possible to do the operation and partition $$$s$$$ into two disjoint subsequences $$$s^p$$$ and $$$s^q$$$, such that $$$s^p = s^q$$$, print elements of $$$b$$$ and indices of $$$s^p$$$, i. e. the values $$$p_1, p_2, \ldots, p_n$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^5$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$), where $$$2n$$$ is the length of the binary string. The second line of each test case contains the binary string $$$s$$$ of length $$$2n$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, follow the following output format. If there is no solution, print $$$-1$$$.  Otherwise,   In the first line, print an integer $$$m$$$ ($$$0 \leq m \leq 2n$$$), followed by $$$m$$$ distinct indices $$$b_1$$$, $$$b_2$$$, ..., $$$b_m$$$(in increasing order).  In the second line, print $$$n$$$ distinct indices $$$p_1$$$, $$$p_2$$$, ..., $$$p_n$$$ (in increasing order).  If there are multiple solutions, print any.

NoteIn the first test case, $$$b$$$ is empty. So string $$$s$$$ is not changed. Now $$$s^p = s_1 s_2 = \mathtt{10}$$$, and $$$s^q = s_3s_4 = \mathtt{10}$$$.In the second test case, $$$b=[3,5]$$$. Initially $$$s_3=\mathtt{0}$$$, and $$$s_5=\mathtt{1}$$$. On performing the operation, we simultaneously set $$$s_3=\mathtt{1}$$$, and $$$s_5=\mathtt{0}$$$.So $$$s$$$ is updated to 101000 on performing the operation.Now if we take characters at indices $$$[1,2,5]$$$ in $$$s^p$$$, we get $$$s_1=\mathtt{100}$$$. Also characters at indices $$$[3,4,6]$$$ are in $$$s^q$$$. Thus $$$s^q=100$$$. We are done as $$$s^p=s^q$$$.In fourth test case, it can be proved that it is not possible to partition the string after performing any operation.


Ela likes Chess a lot. During breaks, she usually challenges her co-worker in DTL to some chess games. She's not an expert at classic chess, but she's very interested in Chess variants, where she has to adapt to new rules and test her tactical mindset to win the game.The problem, which involves a non-standard chess pieces type that is described below, reads: given $$$3$$$ white crickets on a $$$n \cdot n$$$ board, arranged in an "L" shape next to each other, there are no other pieces on the board. Ela wants to know with a finite number of moves, can she put any white cricket on the square on row $$$x$$$, column $$$y$$$?An "L"-shape piece arrangement can only be one of the below:    For simplicity, we describe the rules for crickets on the board where only three white crickets are. It can move horizontally, vertically, or diagonally, but only to a square in some direction that is immediately after another cricket piece (so that it must jump over it). If the square immediately behind the piece is unoccupied, the cricket will occupy the square. Otherwise (when the square is occupied by another cricket, or does not exist), the cricket isn't allowed to make such a move.See an example of valid crickets' moves on the pictures in the Note section.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows. The first line of each test case contains $$$n$$$ ($$$4 \le n \le 10^5$$$) — denotes the size of the chessboard. The second line of each test case contains 6 numbers: $$$r_1$$$, $$$c_1$$$, $$$r_2$$$, $$$c_2$$$, $$$r_3$$$, $$$c_3$$$ ($$$1 \le r_1, c_1, r_2, c_2, r_3, c_3 \le n$$$) — coordinates of the crickets. The input ensures that the three crickets are arranged in an "L" shape that the legend stated. The third line of each test case contains 2 numbers: $$$x$$$, $$$y$$$ ($$$1 \le x, y \le n$$$) — coordinates of the target square.

For each test case, print "YES" or "NO" to denotes whether Ela can put a cricket on the target square.

NoteHere's the solution for the first test case. The red square denotes where the crickets need to reach. Note that in chess horizontals are counted from bottom to top, as well as on this picture.


Ela needs to send a large package from machine $$$1$$$ to machine $$$n$$$ through a network of machines. Currently, with the network condition, she complains that the network is too slow and the package can't arrive in time. Luckily, a Wiring Wizard offered her a helping hand.The network can be represented as an undirected connected graph with $$$n$$$ nodes, each node representing a machine. $$$m$$$ wires are used to connect them. Wire $$$i$$$ is used to connect machines $$$u_i$$$ and $$$v_i$$$, and has a weight $$$w_i$$$. The aforementioned large package, if going through wire $$$i$$$, will move from machine $$$u_i$$$ to machine $$$v_i$$$ (or vice versa) in exactly $$$w_i$$$ microseconds. The Wiring Wizard can use his spell an arbitrary number of times. For each spell, he will choose the wire of index $$$i$$$, connecting machine $$$u_i$$$ and $$$v_i$$$, and rewire it following these steps:  Choose one machine that is connected by this wire. Without loss of generality, let's choose $$$v_i$$$.  Choose a machine that is currently connecting to $$$v_i$$$ (including $$$u_i$$$), call it $$$t_i$$$. Disconnect the wire indexed $$$i$$$ from $$$v_i$$$, then using it to connect $$$u_i$$$ and $$$t_i$$$. The rewiring of wire $$$i$$$ will takes $$$w_i$$$ microseconds, and the weight of the wire will not change after this operation. After a rewiring, a machine might have some wire connect it with itself. Also, the Wiring Wizard has warned Ela that rewiring might cause temporary disconnections between some machines, but Ela just ignores it anyway. Her mission is to send the large package from machine $$$1$$$ to machine $$$n$$$ as fast as possible. Note that the Wizard can use his spell on a wire zero, one, or many times. To make sure the network works seamlessly while transferring the large package, once the package starts transferring from machine $$$1$$$, the Wiring Wizard cannot use his spell to move wires around anymore.Ela wonders, with the help of the Wiring Wizard, what is the least amount of time needed to transfer the large package from machine $$$1$$$ to $$$n$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows. The first line contains $$$n$$$ and $$$m$$$ ($$$2 \le n \le 500$$$, $$$n - 1 \le m \le 250 000$$$), the number of nodes and number of wires, respectively. For the next $$$m$$$ lines, $$$i$$$-th line will contains $$$u_i$$$, $$$v_i$$$ and $$$w_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$1 \le w_i \le 10^9$$$) - the indices 2 machines that are connected by the $$$i$$$-th edge and the weight of it. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$500$$$ and the sum of $$$m$$$ over all test cases does not exceed $$$250 000$$$. The graph in each test case is guaranteed to be connected, no self-loops, but it can contain multiple edges.

For each test case, output one integer denotes the least amount of time needed to transfer the large package from machine $$$1$$$ to $$$n$$$.

NoteHere is the graph in the first test case in the sample input:  Ela can ask the Wiring Wizard to use his spell on wire with the index of $$$7$$$, which is connecting machines $$$2$$$ and $$$3$$$. Then, since the machine $$$8$$$ is connected to machine $$$3$$$, the Wiring Wizard can disconnect wire $$$7$$$ from machine $$$3$$$ and connect it to machine $$$8$$$ in $$$3$$$ microseconds (weight of wire $$$3$$$).After that, the package can be sent from machine $$$1$$$ to machine $$$8$$$ in $$$6$$$ microseconds. Therefore, the answer is $$$3 + 6 = 9$$$ microseconds.Here is the graph in the third test case in the sample input:


DTL engineers love partying in the weekend. Ela does, too! Unfortunately, she didn't know how to dance yet. Therefore, she decided to take a dancing class.There are $$$n$$$ students in the dancing class, including Ela. In the final project, $$$n$$$ students will participate in a choreography described below.$$$n$$$ students are positioned on the positive side of the $$$Ox$$$-axis. The $$$i$$$-th dancer is located at $$$a_i > 0$$$. Some dancers will change positions during the dance (we'll call them movable dancers), and others will stay in the same place during a choreography (we'll call them immovable dancers). We distinguish the dancers using a binary string $$$s$$$ of length $$$n$$$: if $$$s_i$$$ equals '1', then the $$$i$$$-th dancer is movable, otherwise the $$$i$$$-th dancer is immovable.Let's call the "positive energy value" of the choreography $$$d > 0$$$. The dancers will perform "movements" based on this value.Each minute after the dance begins, the movable dancer with the smallest $$$x$$$-coordinate will start moving to the right and initiate a "movement". At the beginning of the movement, the dancer's energy level will be initiated equally to the positive energy value of the choreography, which is $$$d$$$. Each time they move from some $$$y$$$ to $$$y+1$$$, the energy level will be decreased by $$$1$$$. At some point, the dancer might meet other fellow dancers in the same coordinates. If it happens, then the energy level of the dancer will be increased by $$$1$$$. A dancer will stop moving to the right when his energy level reaches $$$0$$$, and he doesn't share a position with another dancer.The dancers are very well-trained, and each "movement" will end before the next minute begins.To show her understanding of this choreography, Ela has to answer $$$q$$$ queries, each consisting of two integers $$$k$$$ and $$$m$$$. The answer to this query is the coordinate of the $$$m$$$-th dancer of both types from the left at $$$k$$$-th minute after the choreography begins. In other words, denote $$$x_{k, 1}, x_{k, 2}, \dots, x_{k, n}$$$ as the sorted coordinates of the dancers at $$$k$$$-th minute from the beginning, you need to print $$$x_{k, m}$$$.

The first line contains three integers $$$n$$$, $$$d$$$ and $$$q$$$ ($$$1 \le n \le 10^5$$$; $$$1 \le d \le 10^9$$$; $$$1 \le q \le 10^5$$$) — the number of dancers, the positive energy value of the choreography, and the number of queries. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_1 < a_2 < \dots < a_n \le 10^9$$$) — the coordinates of each dancer. The third line contains a binary string $$$s$$$ of length $$$n$$$ — the movability of each dancer. Each character is either '0' or '1'. It is guaranteed that $$$s$$$ contains at least one character '1'. Then $$$q$$$ lines follow, the $$$i$$$-th of them contains two integers $$$k_i$$$ and $$$m_i$$$ ($$$1 \le k_i \le 10^9$$$, $$$1 \le m_i \le n$$$) — the content of each query.

Output $$$q$$$ lines, each contains a single integer — the answer for the corresponding query.

NoteLet's consider the first example test case.In the first minute, $$$1$$$ is the lowest coordinate between movable dancers. The energy level is initiated with $$$3$$$. Then the following happens:   The dancer moves from $$$1$$$ to $$$2$$$. The energy level decreased to $$$2$$$.  The dancer moves from $$$2$$$ to $$$3$$$. The energy level decreased to $$$1$$$, then increased to $$$2$$$ when she met another dancer at $$$3$$$.  The dancer moves from $$$3$$$ to $$$4$$$. The energy level decreased to $$$1$$$.  The dancer moves from $$$4$$$ to $$$5$$$. The energy level decreased to $$$0$$$. At the end of the first minute, the sorted coordinates of the dancers become $$$[3, 5, 6, 7]$$$, and their respective movability is '0111'.In the second minute, $$$5$$$ is the lowest coordinate between movable dancers. The energy level is initiated with $$$3$$$. Then the following happens:   The dancer moves from $$$5$$$ to $$$6$$$. The energy level decreased to $$$2$$$, then increased to $$$3$$$ when she met another dancer at $$$6$$$.  The dancer moves from $$$6$$$ to $$$7$$$. The energy level decreased to $$$2$$$, then increased to $$$3$$$ when she met another dancer at $$$7$$$.  The dancer moves from $$$7$$$ to $$$8$$$. The energy level decreased to $$$2$$$.  The dancer moves from $$$8$$$ to $$$9$$$. The energy level decreased to $$$1$$$.  The dancer moves from $$$9$$$ to $$$10$$$. The energy level decreased to $$$0$$$. At the end of the second minute, the sorted coordinates of the dancers become $$$[3, 6, 7, 10]$$$, and their respective movability is '0111'.


After a long, tough, but fruitful day at DTL, Ela goes home happily. She entertains herself by solving Competitive Programming problems. She prefers short statements, because she already read too many long papers and documentation at work. The problem of the day reads:You are given an integer $$$c$$$. Suppose that $$$c$$$ has $$$n$$$ divisors. You have to find a sequence with $$$n - 1$$$ integers $$$[a_1, a_2, ... a_{n - 1}]$$$, which satisfies the following conditions:  Each element is strictly greater than $$$1$$$.  Each element is a divisor of $$$c$$$.  All elements are distinct.  For all $$$1 \le i < n - 1$$$, $$$\gcd(a_i, a_{i + 1})$$$ is a prime number. In this problem, because $$$c$$$ can be too big, the result of prime factorization of $$$c$$$ is given instead. Note that $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$ and a prime number is a positive integer which has exactly $$$2$$$ divisors.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) - the number of test cases. The first line of each test case contains one integer $$$m$$$ ($$$1 \le m \le 16$$$) - the number of prime factor of $$$c$$$. The second line of each test case contains $$$m$$$ integers $$$b_1, b_2, \ldots, b_m$$$ ($$$1 \le b_i < 2^{20}$$$) — exponents of corresponding prime factors of $$$c$$$, so that $$$c = p_1^{b_1} \cdot p_2^{b_2} \cdot \ldots \cdot p_m^{b_m}$$$ and $$$n = (b_1 + 1)(b_2 + 1) \ldots (b_m + 1)$$$ hold. $$$p_i$$$ is the $$$i$$$-th smallest prime number. It is guaranteed that the sum of $$$n \cdot m$$$ over all test cases does not exceed $$$2^{20}$$$.

Print the answer for each test case, one per line. If there is no sequence for the given $$$c$$$, print $$$-1$$$. Otherwise, print $$$n - 1$$$ lines. In $$$i$$$-th line, print $$$m$$$ space-separated integers. The $$$j$$$-th integer of $$$i$$$-th line is equal to the exponent of $$$j$$$-th prime number from $$$a_i$$$. If there are multiple answers, print any of them.

NoteIn each test case, the values of $$$c$$$ are $$$6$$$, $$$2$$$, $$$30$$$, $$$16$$$, and $$$12$$$ in that order.In the first test case, $$$1$$$, $$$2$$$, $$$3$$$, $$$6$$$ are divisors of $$$6$$$. Here, sequences $$$[2, 6, 3]$$$ and $$$[3, 6, 2]$$$ can be answer. Permutation $$$[3, 2, 6]$$$ is invalid because $$$\gcd(a_1, a_2) = 1$$$ is not a prime number.In the forth test case, $$$1$$$, $$$2$$$, $$$4$$$, $$$8$$$, $$$16$$$ are divisors of $$$16$$$. Among the permutation of sequence $$$[2, 4, 8, 16]$$$, no valid answer exist.


Alice and Bob are playing a game on a sequence $$$a_1, a_2, \dots, a_n$$$ of length $$$n$$$. They move in turns and Alice moves first.In the turn of each player, he or she should select an integer and remove it from the sequence. The game ends when there is no integer left in the sequence. Alice wins if the sum of her selected integers is even; otherwise, Bob wins. Your task is to determine who will win the game, if both players play optimally.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 100$$$), indicating the length of the sequence. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \leq a_i \leq 10^9$$$), indicating the elements of the sequence.

For each test case, output "Alice" (without quotes) if Alice wins and "Bob" (without quotes) otherwise.

NoteIn the first and second test cases, Alice always selects two odd numbers, so the sum of her selected numbers is always even. Therefore, Alice always wins.In the third test case, Bob has a winning strategy that he always selects a number with the same parity as Alice selects in her last turn. Therefore, Bob always wins.In the fourth test case, Alice always selects two even numbers, so the sum of her selected numbers is always even. Therefore, Alice always wins.


Given a permutation $$$a_1, a_2, \dots, a_n$$$ of integers from $$$1$$$ to $$$n$$$, and a threshold $$$k$$$ with $$$0 \leq k \leq n$$$, you compute a sequence $$$b_1, b_2, \dots, b_n$$$ as follows. For every $$$1 \leq i \leq n$$$ in increasing order, let $$$x = a_i$$$.   If $$$x \leq k$$$, set $$$b_{x}$$$ to the last element $$$a_j$$$ ($$$1 \leq j < i$$$) that $$$a_j > k$$$. If no such element $$$a_j$$$ exists, set $$$b_{x} = n+1$$$.  If $$$x > k$$$, set $$$b_{x}$$$ to the last element $$$a_j$$$ ($$$1 \leq j < i$$$) that $$$a_j \leq k$$$. If no such element $$$a_j$$$ exists, set $$$b_{x} = 0$$$. Unfortunately, after the sequence $$$b_1, b_2, \dots, b_n$$$ has been completely computed, the permutation $$$a_1, a_2, \dots, a_n$$$ and the threshold $$$k$$$ are discarded. Now you only have the sequence $$$b_1, b_2, \dots, b_n$$$. Your task is to find any possible permutation $$$a_1, a_2, \dots, a_n$$$ and threshold $$$k$$$ that produce the sequence $$$b_1, b_2, \dots, b_n$$$. It is guaranteed that there exists at least one pair of permutation $$$a_1, a_2, \dots, a_n$$$ and threshold $$$k$$$ that produce the sequence $$$b_1, b_2, \dots, b_n$$$.A permutation of integers from $$$1$$$ to $$$n$$$ is a sequence of length $$$n$$$ which contains all integers from $$$1$$$ to $$$n$$$ exactly once.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$), indicating the length of the permutation $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$0 \leq b_i \leq n+1$$$), indicating the elements of the sequence $$$b$$$. It is guaranteed that there exists at least one pair of permutation $$$a_1, a_2, \dots, a_n$$$ and threshold $$$k$$$ that produce the sequence $$$b_1, b_2, \dots, b_n$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output the threshold $$$k$$$ ($$$0 \leq k \leq n$$$) in the first line, and then output the permutation $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq n$$$) in the second line such that the permutation $$$a_1, a_2, \dots, a_n$$$ and threshold $$$k$$$ produce the sequence $$$b_1, b_2, \dots, b_n$$$. If there are multiple solutions, you can output any of them.

NoteFor the first test case, permutation $$$a = [1,3,2,4]$$$ and threshold $$$k = 2$$$ will produce sequence $$$b$$$ as follows.   When $$$i = 1$$$, $$$x = a_i = 1 \leq k$$$, there is no $$$a_j$$$ ($$$1 \leq j < i$$$) that $$$a_j > k$$$. Therefore, $$$b_1 = n + 1 = 5$$$.  When $$$i = 2$$$, $$$x = a_i = 3 > k$$$, the last element $$$a_j$$$ that $$$a_j \leq k$$$ is $$$a_1$$$. Therefore, $$$b_3 = a_1 = 1$$$.  When $$$i = 3$$$, $$$x = a_i = 2 \leq k$$$, the last element $$$a_j$$$ that $$$a_j > k$$$ is $$$a_2$$$. Therefore, $$$b_2 = a_2 = 3$$$.  When $$$i = 4$$$, $$$x = a_i = 4 > k$$$, the last element $$$a_j$$$ that $$$a_j \leq k$$$ is $$$a_3$$$. Therefore, $$$b_4 = a_3 = 2$$$.  Finally, we obtain sequence $$$b = [5,3,1,2]$$$. For the second test case, permutation $$$a = [1,2,3,4,5,6]$$$ and threshold $$$k = 3$$$ will produce sequence $$$b$$$ as follows.   When $$$i = 1, 2, 3$$$, $$$a_i \leq k$$$, there is no $$$a_j$$$ ($$$1 \leq j < i$$$) that $$$a_j > k$$$. Therefore, $$$b_1 = b_2 = b_3 = n + 1 = 7$$$.  When $$$i = 4, 5, 6$$$, $$$a_i > k$$$, the last element $$$a_j$$$ that $$$a_j \leq k$$$ is $$$a_3$$$. Therefore, $$$b_4 = b_5 = b_6 = a_3 = 3$$$.  Finally, we obtain sequence $$$b = [7,7,7,3,3,3]$$$. For the third test case, permutation $$$a = [6,5,4,3,2,1]$$$ and threshold $$$k = 3$$$ will produce sequence $$$b$$$ as follows.   When $$$i = 1, 2, 3$$$, $$$a_i > k$$$, there is no $$$a_j$$$ ($$$1 \leq j < i$$$) that $$$a_j \leq k$$$. Therefore, $$$b_4 = b_5 = b_6 = 0$$$.  When $$$i = 4, 5, 6$$$, $$$a_i \leq k$$$, the last element $$$a_j$$$ that $$$a_j > k$$$ is $$$a_3$$$. Therefore, $$$b_1 = b_2 = b_3 = a_3 = 4$$$.  Finally, we obtain sequence $$$b = [4,4,4,0,0,0]$$$.


Given an integer sequence $$$a_1, a_2, \dots, a_n$$$ of length $$$n$$$, your task is to compute the number, modulo $$$998244353$$$, of ways to partition it into several non-empty continuous subsequences such that the sums of elements in the subsequences form a balanced sequence.A sequence $$$s_1, s_2, \dots, s_k$$$ of length $$$k$$$ is said to be balanced, if $$$s_{i} = s_{k-i+1}$$$ for every $$$1 \leq i \leq k$$$. For example, $$$[1, 2, 3, 2, 1]$$$ and $$$[1,3,3,1]$$$ are balanced, but $$$[1,5,15]$$$ is not. Formally, every partition can be described by a sequence of indexes $$$i_1, i_2, \dots, i_k$$$ of length $$$k$$$ with $$$1 = i_1 < i_2 < \dots < i_k \leq n$$$ such that   $$$k$$$ is the number of non-empty continuous subsequences in the partition;  For every $$$1 \leq j \leq k$$$, the $$$j$$$-th continuous subsequence starts with $$$a_{i_j}$$$, and ends exactly before $$$a_{i_{j+1}}$$$, where $$$i_{k+1} = n + 1$$$. That is, the $$$j$$$-th subsequence is $$$a_{i_j}, a_{i_j+1}, \dots, a_{i_{j+1}-1}$$$.  There are $$$2^{n-1}$$$ different partitions in total. Let $$$s_1, s_2, \dots, s_k$$$ denote the sums of elements in the subsequences with respect to the partition $$$i_1, i_2, \dots, i_k$$$. Formally, for every $$$1 \leq j \leq k$$$, $$$$$$ s_j = \sum_{i=i_{j}}^{i_{j+1}-1} a_i = a_{i_j} + a_{i_j+1} + \dots + a_{i_{j+1}-1}. $$$$$$ For example, the partition $$$[1\,|\,2,3\,|\,4,5,6]$$$ of sequence $$$[1,2,3,4,5,6]$$$ is described by the sequence $$$[1,2,4]$$$ of indexes, and the sums of elements in the subsequences with respect to the partition is $$$[1,5,15]$$$.Two partitions $$$i_1, i_2, \dots, i_k$$$ and $$$i'_1, i'_2, \dots, i'_{k'}$$$ (described by sequences of indexes) are considered to be different, if at least one of the following holds.   $$$k \neq k'$$$,  $$$i_j \neq i'_j$$$ for some $$$1 \leq j \leq \min\left\{ k, k' \right\}$$$.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$), indicating the length of the sequence $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \leq a_i \leq 10^9$$$), indicating the elements of the sequence $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output the number of partitions with respect to which the sum of elements in each subsequence is balanced, modulo $$$998244353$$$.

NoteFor the first test case, there is only one way to partition a sequence of length $$$1$$$, which is itself and is, of course, balanced. For the second test case, there are $$$2$$$ ways to partition it:   The sequence $$$[1, 1]$$$ itself, then $$$s = [2]$$$ is balanced;  Partition into two subsequences $$$[1\,|\,1]$$$, then $$$s = [1, 1]$$$ is balanced. For the third test case, there are $$$3$$$ ways to partition it:   The sequence $$$[0, 0, 1, 0]$$$ itself, then $$$s = [1]$$$ is balanced;  $$$[0 \,|\, 0, 1 \,|\, 0]$$$, then $$$s = [0, 1, 0]$$$ is balanced;  $$$[0, 0 \,|\, 1 \,|\, 0]$$$, then $$$s = [0, 1, 0]$$$ is balanced. For the fourth test case, there are $$$4$$$ ways to partition it:   The sequence $$$[1, 2, 3, 2, 1]$$$ itself, then $$$s = [9]$$$ is balanced;  $$$[1, 2 \,|\, 3 \,|\, 2, 1]$$$, then $$$s = [3, 3, 3]$$$ is balanced;  $$$[1 \,|\, 2, 3, 2 \,|\, 1]$$$, then $$$s = [1, 7, 1]$$$ is balanced;  $$$[1 \,|\, 2 \,|\, 3 \,|\, 2 \,|\, 1]$$$, then $$$s = [1, 2, 3, 2, 1]$$$ is balanced. For the fifth test case, there are $$$2$$$ ways to partition it:   The sequence $$$[1, 3, 5, 7, 9]$$$ itself, then $$$s = [25]$$$ is balanced;  $$$[1, 3, 5 \,|\, 7 \,|\, 9]$$$, then $$$s = [9, 7, 9]$$$ is balanced. For the sixth test case, every possible partition should be counted. So the answer is $$$2^{32-1} \equiv 150994942 \pmod {998244353}$$$.


The hero is addicted to glory, and is fighting against a monster. The hero has $$$n$$$ skills. The $$$i$$$-th skill is of type $$$a_i$$$ (either fire or frost) and has initial damage $$$b_i$$$. The hero can perform all of the $$$n$$$ skills in any order (with each skill performed exactly once). When performing each skill, the hero can play a magic as follows:   If the current skill immediately follows another skill of a different type, then its damage is doubled.  In other words,   If a skill of type fire and with initial damage $$$c$$$ is performed immediately after a skill of type fire, then it will deal $$$c$$$ damage;  If a skill of type fire and with initial damage $$$c$$$ is performed immediately after a skill of type frost, then it will deal $$$2c$$$ damage;  If a skill of type frost and with initial damage $$$c$$$ is performed immediately after a skill of type fire, then it will deal $$$2c$$$ damage;  If a skill of type frost and with initial damage $$$c$$$ is performed immediately after a skill of type frost , then it will deal $$$c$$$ damage. Your task is to find the maximum damage the hero can deal.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$), indicating the number of skills.  The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \leq a_i \leq 1$$$), where $$$a_i$$$ indicates the type of the $$$i$$$-th skill. Specifically, the $$$i$$$-th skill is of type fire if $$$a_i = 0$$$, and of type frost if $$$a_i = 1$$$.  The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \leq b_i \leq 10^9$$$), where $$$b_i$$$ indicates the initial damage of the $$$i$$$-th skill.  It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output the maximum damage the hero can deal.

NoteIn the first test case, we can order the skills by $$$[3, 1, 4, 2]$$$, and the total damage is $$$100 + 2 \times 1 + 2 \times 1000 + 10 = 2112$$$.In the second test case, we can order the skills by $$$[1, 4, 2, 5, 3, 6]$$$, and the total damage is $$$3 + 2 \times 6 + 2 \times 4 + 2 \times 7 + 2 \times 5 + 2 \times 8 = 63$$$.In the third test case, we can order the skills by $$$[1, 2, 3]$$$, and the total damage is $$$1000000000 + 1000000000 + 1000000000 = 3000000000$$$.In the fourth test case, there is only one skill with initial damage $$$1$$$, so the total damage is $$$1$$$.


You are given an $$$n \times n$$$ grid. We write $$$(i, j)$$$ to denote the cell in the $$$i$$$-th row and $$$j$$$-th column. For each cell, you are told whether yon can delete it or not. Given an integer $$$k$$$, you are asked to delete exactly $$$(n-k+1)^2$$$ cells from the grid such that the following condition holds.   You cannot find $$$k$$$ not deleted cells $$$(x_1, y_1), (x_2, y_2), \dots, (x_k, y_k)$$$ that are strictly increasing, i.e., $$$x_i < x_{i+1}$$$ and $$$y_i < y_{i+1}$$$ for all $$$1 \leq i < k$$$.  Your task is to find a solution, or report that it is impossible.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \leq k \leq n \leq 1000$$$).  Then $$$n$$$ lines follow. The $$$i$$$-th line contains a binary string $$$s_i$$$ of length $$$n$$$. The $$$j$$$-th character of $$$s_i$$$ is 1 if you can delete cell $$$(i, j)$$$, and 0 otherwise. It's guaranteed that the sum of $$$n^2$$$ over all test cases does not exceed $$$10^6$$$.

For each test case, if there is no way to delete exactly $$$(n-k+1)^2$$$ cells to meet the condition, output "NO" (without quotes). Otherwise, output "YES" (without quotes). Then, output $$$n$$$ lines. The $$$i$$$-th line should contain a binary string $$$t_i$$$ of length $$$n$$$. The $$$j$$$-th character of $$$t_i$$$ is 0 if cell $$$(i, j)$$$ is deleted, and 1 otherwise. If there are multiple solutions, you can output any of them. You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).

NoteFor the first test case, you only have to delete cell $$$(1, 1)$$$.For the second test case, you could choose to delete cells $$$(1,1)$$$, $$$(1,2)$$$, $$$(4,3)$$$ and $$$(4,4)$$$.For the third test case, it is no solution because the cells in the diagonal will always form a strictly increasing sequence of length $$$5$$$.


Your task is to maintain a queue consisting of lowercase English letters as follows:   "push $$$c$$$": insert a letter $$$c$$$ at the back of the queue;  "pop": delete a letter from the front of the queue. Initially, the queue is empty. After each operation, you are asked to count the number of distinct palindromic substrings in the string that are obtained by concatenating the letters from the front to the back of the queue.Especially, the number of distinct palindromic substrings of the empty string is $$$0$$$. A string $$$s[1..n]$$$ of length $$$n$$$ is palindromic if $$$s[i] = s[n-i+1]$$$ for every $$$1 \leq i \leq n$$$. The string $$$s[l..r]$$$ is a substring of string $$$s[1..n]$$$ for every $$$1 \leq l \leq r \leq n$$$. Two strings $$$s[1..n]$$$ and $$$t[1..m]$$$ are distinct, if at least one of the following holds.   $$$n \neq m$$$;  $$$s[i] \neq t[i]$$$ for some $$$1 \leq i \leq \min\{n,m\}$$$.

The first line is an integer $$$q$$$ ($$$1 \leq q \leq 10^6$$$), indicating the number of operations. Then $$$q$$$ lines follow. Each of the following lines contains one of the operations as follows.    "push $$$c$$$": insert a letter $$$c$$$ at the back of the queue, where $$$c$$$ is a lowercase English letter;  "pop": delete a letter from the front of the queue.  It is guaranteed that no "pop" operation will be performed when the queue is empty.

After each operation, print the number of distinct palindromic substrings in the string presented in the queue.

NoteLet $$$s_k$$$ be the string presented in the queue after the $$$k$$$-th operation, and let $$$c_k$$$ be the number of distinct palindromic substrings of $$$s_k$$$. The following table shows the details of the example. $$$k$$$$$$s_k$$$$$$c_k$$$$$$1$$$$$$a$$$$$$1$$$$$$2$$$$$$\textsf{empty}$$$$$$0$$$$$$3$$$$$$a$$$$$$1$$$$$$4$$$$$$aa$$$$$$2$$$$$$5$$$$$$aab$$$$$$3$$$$$$6$$$$$$aabb$$$$$$4$$$$$$7$$$$$$aabba$$$$$$5$$$$$$8$$$$$$aabbaa$$$$$$6$$$$$$9$$$$$$abbaa$$$$$$5$$$$$$10$$$$$$bbaa$$$$$$4$$$$$$11$$$$$$baa$$$$$$3$$$$$$12$$$$$$baab$$$$$$4$$$ It is worth pointing out that   After the $$$2$$$-nd operation, the string is empty and thus has no substrings. So the answer is $$$0$$$;  After the $$$8$$$-th operation, the string is "$$$aabbaa$$$". The $$$6$$$ distinct palindromic substrings are "$$$a$$$", "$$$aa$$$", "$$$aabbaa$$$", "$$$abba$$$", "$$$b$$$", and "$$$bb$$$".

12
push a
pop
push a
push a
push b
push b
push a
push a
pop
pop
pop
push b


This is an interactive problem.Given a simple undirected graph with $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$, your task is to color all the vertices such that for every color $$$c$$$, the following conditions hold:   The set of vertices with color $$$c$$$ is connected;  $$$s_c \leq n_c^2$$$, where $$$n_c$$$ is the number of vertices with color $$$c$$$, and $$$s_c$$$ is the sum of degrees of vertices with color $$$c$$$.  It can be shown that there always exists a way to color all the vertices such that the above conditions hold. Initially, you are only given the number $$$n$$$ of vertices and the degree of each vertex. In each query, you can choose a vertex $$$u$$$. As a response, you will be given the $$$k$$$-th edge incident to $$$u$$$, if this is the $$$k$$$-th query on vertex $$$u$$$. You are allowed to make at most $$$n$$$ queries.An undirected graph is simple if it does not contain multiple edges or self-loops.The degree of a vertex is the number of edges incident to it. A set $$$S$$$ of vertices is connected if for every two different vertices $$$u, v \in S$$$, there is a path, which only passes through vertices in $$$S$$$, that connects $$$u$$$ and $$$v$$$. That is, there is a sequence of edges $$$(u_1, v_1), (u_2, v_2), \dots, (u_k, v_k)$$$ with $$$k \geq 1$$$ such that   $$$u_1 = u$$$, $$$v_k = v$$$, and $$$v_i = u_{i+1}$$$ for every $$$1 \leq i < k$$$; and  $$$u_k \in S$$$ and $$$v_k \in S$$$ for every $$$1 \leq i \leq k$$$.  Especially, a set containing only one vertex is connected.

NoteIn the example, there is only one test case. In the test case, there are $$$n = 5$$$ vertices with vertices $$$1, 2, 3, 4$$$ of degree $$$2$$$ and vertex $$$5$$$ of degree $$$0$$$. It is obvious that vertex $$$5$$$ is isolated, i.e., it does not connect to any other vertices. A possible interaction is shown in the sample input and output, where $$$4$$$ "?" queries are made on vertex $$$1$$$ twice and vertex $$$3$$$ twice. According to the responses to these queries, we know that each of vertex $$$1$$$ and vertex $$$3$$$ connects to two vertices $$$2$$$ and $$$4$$$. A possible solution is shown in the sample output, where vertex $$$1$$$ and vertex $$$2$$$ are colored by $$$1$$$, vertex $$$3$$$ and vertex $$$4$$$ are colored by $$$2$$$, and vertex $$$5$$$ is colored by $$$3$$$. It can be seen that this solution satisfies the required conditions as follows.   For color $$$c = 1$$$, vertex $$$1$$$ and vertex $$$2$$$ are connected. Moreover, $$$n_1 = 2$$$ and $$$s_1 = d_1 + d_2 = 2 + 2 = 4 \leq n_1^2 = 2^2 = 4$$$;  For color $$$c = 2$$$, vertex $$$3$$$ and vertex $$$4$$$ are connected. Moreover, $$$n_2 = 2$$$ and $$$s_2 = d_3 + d_4 = 2 + 2 = 4 \leq n_2^2 = 2^2 = 4$$$;  For color $$$c = 3$$$, there is only one vertex (vertex $$$5$$$) colored by $$$3$$$. Moreover, $$$n_3 = 1$$$ and $$$s_3 = d_5 = 0 \leq n_3^2 = 1^2 = 1$$$.


Suppose $$$a_1, a_2, \dots, a_n$$$ is a sorted integer sequence of length $$$n$$$ such that $$$a_1 \leq a_2 \leq \dots \leq a_n$$$. For every $$$1 \leq i \leq n$$$, the prefix sum $$$s_i$$$ of the first $$$i$$$ terms $$$a_1, a_2, \dots, a_i$$$ is defined by $$$$$$ s_i = \sum_{k=1}^i a_k = a_1 + a_2 + \dots + a_i. $$$$$$Now you are given the last $$$k$$$ terms of the prefix sums, which are $$$s_{n-k+1}, \dots, s_{n-1}, s_{n}$$$. Your task is to determine whether this is possible. Formally, given $$$k$$$ integers $$$s_{n-k+1}, \dots, s_{n-1}, s_{n}$$$, the task is to check whether there is a sequence $$$a_1, a_2, \dots, a_n$$$ such that   $$$a_1 \leq a_2 \leq \dots \leq a_n$$$, and  $$$s_i = a_1 + a_2 + \dots + a_i$$$ for all $$$n-k+1 \leq i \leq n$$$.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains two integers $$$n$$$ ($$$1 \leq n \leq 10^5$$$) and $$$k$$$ ($$$1 \leq k \leq n$$$), indicating the length of the sequence $$$a$$$ and the number of terms of prefix sums, respectively. The second line of each test case contains $$$k$$$ integers $$$s_{n-k+1}, \dots, s_{n-1}, s_{n}$$$ ($$$-10^9 \leq s_i \leq 10^9$$$ for every $$$n-k+1 \leq i \leq n$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output "YES" (without quotes) if it is possible and "NO" (without quotes) otherwise. You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).

NoteIn the first test case, we have the only sequence $$$a = [1, 1, 1, 1, 1]$$$.In the second test case, we can choose, for example, $$$a = [-3, -2, -1, 0, 1, 2, 3]$$$.In the third test case, the prefix sums define the only sequence $$$a = [2, 1, 1]$$$, but it is not sorted. In the fourth test case, it can be shown that there is no sequence with the given prefix sums.


There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction:   Find any isolated cell on the board. If there are no such cells, print any cell on the board.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board.

For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board.

NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle.


Consider a game with $$$n$$$ cards ($$$n$$$ is even). Each card has a number written on it, between $$$1$$$ and $$$n$$$. All numbers on the cards are different. We say that a card with number $$$x$$$ is stronger than a card with number $$$y$$$ if $$$x > y$$$.Two players, Alex and Boris, play this game. In the beginning, each of them receives exactly $$$\frac{n}{2}$$$ cards, so each card belongs to exactly one player. Then, they take turns. Alex goes first, then Boris, then Alex again, and so on.On a player's turn, he must play exactly one of his cards. Then, if the opponent doesn't have any cards stronger than the card played, the opponent loses, and the game ends. Otherwise, the opponent has to play a stronger card (exactly one card as well). These two cards are removed from the game, and the turn ends. If there are no cards left, the game ends in a draw; otherwise it's the opponent's turn.Consider all possible ways to distribute the cards between two players, so that each of them receives exactly half of the cards. You have to calculate three numbers:  the number of ways to distribute the cards so that Alex wins;  the number of ways to distribute the cards so that Boris wins;  the number of ways to distribute the cards so that the game ends in a draw. You may assume that both players play optimally (i. e. if a player can win no matter how his opponent plays, he wins). Two ways to distribute the cards are different if there is at least one card such that, in one of these ways, it is given to Alex, and in the other way, it is given to Boris.For example, suppose $$$n = 4$$$, Alex receives the cards $$$[2, 3]$$$, and Boris receives the cards $$$[1, 4]$$$. Then the game may go as follows:  if Alex plays the card $$$2$$$, then Boris has to respond with the card $$$4$$$. Then, Alex's turn ends, and Boris' turn starts. Boris has only one card left, which is $$$1$$$; he plays it, and Alex responds with the card $$$3$$$. So, the game ends in a draw;  if Alex plays the card $$$3$$$, then Boris has to respond with the card $$$4$$$. Then, Alex's turn ends, and Boris' turn starts. Boris has only one card left, which is $$$1$$$; he plays it, and Alex responds with the card $$$2$$$. So, the game ends in a draw. So, in this case, the game ends in a draw.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 30$$$) — the number of test cases. Then, $$$t$$$ lines follow. The $$$i$$$-th line contains one even integer $$$n$$$ ($$$2 \le n \le 60$$$).

For each test case, print three integers:   the number of ways to distribute the cards so that Alex wins;  the number of ways to distribute the cards so that Boris wins;  the number of ways to distribute the cards so that the game ends in a draw.  Since the answers can be large, print them modulo $$$998244353$$$.

NoteIn the first test case, Alex wins if he receives the card $$$2$$$ (he plays it, and Boris cannot respond). If Alex receives the card $$$1$$$, the game ends in a draw.In the second test case:   Alex wins if he receives the cards $$$[3, 4]$$$, $$$[2, 4]$$$ or $$$[1, 4]$$$;  Boris wins if Alex receives the cards $$$[1, 2]$$$ or $$$[1, 3]$$$;  the game ends in a draw if Alex receives the cards $$$[2, 3]$$$.


You are given a rooted tree, consisting of $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$, the root is the vertex $$$1$$$.You can perform the following operation at most $$$k$$$ times:   choose an edge $$$(v, u)$$$ of the tree such that $$$v$$$ is a parent of $$$u$$$;  remove the edge $$$(v, u)$$$;  add an edge $$$(1, u)$$$ (i. e. make $$$u$$$ with its subtree a child of the root). The height of a tree is the maximum depth of its vertices, and the depth of a vertex is the number of edges on the path from the root to it. For example, the depth of vertex $$$1$$$ is $$$0$$$, since it's the root, and the depth of all its children is $$$1$$$.What's the smallest height of the tree that can be achieved?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$0 \le k \le n - 1$$$) — the number of vertices in the tree and the maximum number of operations you can perform. The second line contains $$$n-1$$$ integers $$$p_2, p_3, \dots, p_n$$$ ($$$1 \le p_i < i$$$) — the parent of the $$$i$$$-th vertex. Vertex $$$1$$$ is the root. The sum of $$$n$$$ over all testcases doesn't exceed $$$2 \cdot 10^5$$$.

For each testcase, print a single integer — the smallest height of the tree that can achieved by performing at most $$$k$$$ operations.


For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le 100$$$) — the elements of the array $$$d$$$. It can be shown that there always exists at least one suitable array $$$a$$$ under these constraints.

For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$.

NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$.


Consider a hallway, which can be represented as the matrix with $$$2$$$ rows and $$$n$$$ columns. Let's denote the cell on the intersection of the $$$i$$$-th row and the $$$j$$$-th column as $$$(i, j)$$$. The distance between the cells $$$(i_1, j_1)$$$ and $$$(i_2, j_2)$$$ is $$$|i_1 - i_2| + |j_1 - j_2|$$$.There is a cleaning robot in the cell $$$(1, 1)$$$. Some cells of the hallway are clean, other cells are dirty (the cell with the robot is clean). You want to clean the hallway, so you are going to launch the robot to do this.After the robot is launched, it works as follows. While at least one cell is dirty, the robot chooses the closest (to its current cell) cell among those which are dirty, moves there and cleans it (so the cell is no longer dirty). After cleaning a cell, the robot again finds the closest dirty cell to its current cell, and so on. This process repeats until the whole hallway is clean.However, there is a critical bug in the robot's program. If at some moment, there are multiple closest (to the robot's current position) dirty cells, the robot malfunctions.You want to clean the hallway in such a way that the robot doesn't malfunction. Before launching the robot, you can clean some (possibly zero) of the dirty cells yourself. However, you don't want to do too much dirty work yourself while you have this nice, smart (yet buggy) robot to do this. Note that you cannot make a clean cell dirty.Calculate the maximum possible number of cells you can leave dirty before launching the robot, so that it doesn't malfunction.

The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of columns in the hallway. Then two lines follow, denoting the $$$1$$$-st and the $$$2$$$-nd row of the hallway. These lines contain $$$n$$$ characters each, where 0 denotes a clean cell and 1 denotes a dirty cell. The starting cell of the robot $$$(1, 1)$$$ is clean.

Print one integer — the maximum possible number of cells you can leave dirty before launching the robot, so that it doesn't malfunction.

NoteIn the first example, you can clean the cell $$$(1, 2)$$$, so the path of the robot is $$$(1, 1) \rightarrow (2, 1) \rightarrow (2, 2)$$$.In the second example, you can leave the hallway as it is, so the path of the robot is $$$(1, 1) \rightarrow (1, 2) \rightarrow (2, 2)$$$.In the third example, you can clean the cell $$$(1, 2)$$$, so the path of the robot is $$$(1, 1) \rightarrow (2, 1) \rightarrow (2, 3) \rightarrow (2, 4) \rightarrow (1, 4)$$$.In the fourth example, the hallway is already clean. Maybe you have launched the robot earlier?


Pak Chanek has $$$n$$$ two-dimensional slices of cheese. The $$$i$$$-th slice of cheese can be represented as a rectangle of dimensions $$$a_i \times b_i$$$. We want to arrange them on the two-dimensional plane such that:  Each edge of each cheese is parallel to either the x-axis or the y-axis.  The bottom edge of each cheese is a segment of the x-axis.  No two slices of cheese overlap, but their sides can touch.  They form one connected shape. Note that we can arrange them in any order (the leftmost slice of cheese is not necessarily the first slice of cheese). Also note that we can rotate each slice of cheese in any way as long as all conditions still hold.Find the minimum possible perimeter of the constructed shape.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 2 \cdot 10^4$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$) — the number of slices of cheese Pak Chanek has. The $$$i$$$-th of the next $$$n$$$ lines of each test case contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \leq a_i,b_i \leq 10^9$$$) — the dimensions of the $$$i$$$-th slice of cheese. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, output a line containing an integer representing the minimum possible perimeter of the constructed shape.

NoteIn the first test case, a way of getting the minimum possible perimeter is to arrange the slices of cheese as follows.We can calculate that the perimeter of the constructed shape is $$$2+5+1+1+1+1+3+1+5+1+2+3=26$$$. It can be shown that we cannot get a smaller perimeter.Consider the following invalid arrangement.Even though the perimeter of the shape above is $$$24$$$, it does not satisfy all conditions of the problem. The bottom edge of the $$$1 \times 1$$$ slice of cheese is not a segment of the x-axis.In the second test case, a way of getting the minimum possible perimeter is to arrange the slices of cheese as follows.We can calculate that the perimeter of the constructed shape is $$$2+2+2+3+2+3+2+2+2+4=24$$$. It can be shown that we cannot get a smaller perimeter.


There are $$$n$$$ bricks numbered from $$$1$$$ to $$$n$$$. Brick $$$i$$$ has a weight of $$$a_i$$$.Pak Chanek has $$$3$$$ bags numbered from $$$1$$$ to $$$3$$$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick.After Pak Chanek distributes the bricks, Bu Dengklek will take exactly one brick from each bag. Let $$$w_j$$$ be the weight of the brick Bu Dengklek takes from bag $$$j$$$. The score is calculated as $$$|w_1 - w_2| + |w_2 - w_3|$$$, where $$$|x|$$$ denotes the absolute value of $$$x$$$.It is known that Bu Dengklek will take the bricks in such a way that minimises the score. What is the maximum possible final score if Pak Chanek distributes the bricks optimally?

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 2 \cdot 10^4$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains an integer $$$n$$$ ($$$3 \leq n \leq 2 \cdot 10^5$$$) — the number of bricks. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$) — the weights of the bricks. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, output a line containing an integer representing the maximum possible final score if Pak Chanek distributes the bricks optimally.

NoteIn the first test case, one way of achieving a final score of $$$6$$$ is to do the following:   Put bricks $$$1$$$, $$$4$$$, and $$$5$$$ into bag $$$1$$$.  Put brick $$$3$$$ into bag $$$2$$$.  Put brick $$$2$$$ into bag $$$3$$$. If Pak Chanek distributes the bricks that way, a way Bu Dengklek can take the bricks is:   Take brick $$$5$$$ from bag $$$1$$$.  Take brick $$$3$$$ from bag $$$2$$$.  Take brick $$$2$$$ from bag $$$3$$$. The score is $$$|a_5 - a_3| + |a_3 - a_2| = |3 - 5| + |5 - 1| = 6$$$. It can be shown that Bu Dengklek cannot get a smaller score from this distribution.It can be shown that there is no other distribution that results in a final score bigger than $$$6$$$.


Monocarp has a dictionary of $$$n$$$ words, consisting of $$$12$$$ first letters of the Latin alphabet. The words are numbered from $$$1$$$ to $$$n$$$. In every pair of adjacent characters in each word, the characters are different. For every word $$$i$$$, Monocarp also has an integer $$$c_i$$$ denoting how often he uses this word.Monocarp wants to design a keyboard that would allow him to type some of the words easily. A keyboard can be denoted as a sequence of $$$12$$$ first letters of the Latin alphabet, where each letter from a to l appears exactly once.A word can be typed with the keyboard easily if, for every pair of adjacent characters in the word, these characters are adjacent in the keyboard as well. The optimality of the keyboard is the sum of $$$c_i$$$ over all words $$$i$$$ that can be typed easily with it.Help Monocarp to design a keyboard with the maximum possible optimality.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of words. Then, $$$n$$$ lines follow. The $$$i$$$-th of them contains an integer $$$c_i$$$ ($$$1 \le c_i \le 10^5$$$) and a string $$$s_i$$$ ($$$2 \le |s_i| \le 2000$$$) denoting the $$$i$$$-th word. Each character of $$$s_i$$$ is one of $$$12$$$ first letters of Latin alphabet, in lowercase. For every $$$j \in [1, |s_i| - 1]$$$, the $$$j$$$-th character of $$$s_i$$$ is different from the $$$(j+1)$$$-th one. Additional constraint on the input: $$$\sum \limits_{i=1}^{n} |s_i| \le 2000$$$.

Print a sequence of $$$12$$$ first letters of the Latin alphabet, where each letter from a to l appears exactly once, denoting the optimal keyboard. If there are multiple answers, you may print any of them.


Pak Chanek has $$$n$$$ blank heart-shaped cards. Card $$$1$$$ is attached directly to the wall while each of the other cards is hanging onto exactly one other card by a piece of string. Specifically, card $$$i$$$ ($$$i > 1$$$) is hanging onto card $$$p_i$$$ ($$$p_i < i$$$).In the very beginning, Pak Chanek must write one integer number on each card. He does this by choosing any permutation $$$a$$$ of $$$[1, 2, \dots, n]$$$. Then, the number written on card $$$i$$$ is $$$a_i$$$.After that, Pak Chanek must do the following operation $$$n$$$ times while maintaining a sequence $$$s$$$ (which is initially empty):  Choose a card $$$x$$$ such that no other cards are hanging onto it.  Append the number written on card $$$x$$$ to the end of $$$s$$$.  If $$$x \neq 1$$$ and the number on card $$$p_x$$$ is larger than the number on card $$$x$$$, replace the number on card $$$p_x$$$ with the number on card $$$x$$$.  Remove card $$$x$$$. After that, Pak Chanek will have a sequence $$$s$$$ with $$$n$$$ elements. What is the maximum length of the longest non-decreasing subsequence$$$^\dagger$$$ of $$$s$$$ at the end if Pak Chanek does all the steps optimally?$$$^\dagger$$$ A sequence $$$b$$$ is a subsequence of a sequence $$$c$$$ if $$$b$$$ can be obtained from $$$c$$$ by deletion of several (possibly, zero or all) elements. For example, $$$[3,1]$$$ is a subsequence of $$$[3,2,1]$$$, $$$[4,3,1]$$$ and $$$[3,1]$$$, but not $$$[1,3,3,7]$$$ and $$$[3,10,4]$$$.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of heart-shaped cards. The second line contains $$$n - 1$$$ integers $$$p_2, p_3, \dots, p_n$$$ ($$$1 \le p_i < i$$$) describing which card that each card hangs onto.

Print a single integer — the maximum length of the longest non-decreasing subsequence of $$$s$$$ at the end if Pak Chanek does all the steps optimally.

NoteThe following is the structure of the cards in the first example.Pak Chanek can choose the permutation $$$a = [1, 5, 4, 3, 2, 6]$$$.Let $$$w_i$$$ be the number written on card $$$i$$$. Initially, $$$w_i = a_i$$$. Pak Chanek can do the following operations in order:  Select card $$$5$$$. Append $$$w_5 = 2$$$ to the end of $$$s$$$. As $$$w_4 > w_5$$$, the value of $$$w_4$$$ becomes $$$2$$$. Remove card $$$5$$$. After this operation, $$$s = [2]$$$.  Select card $$$6$$$. Append $$$w_6 = 6$$$ to the end of $$$s$$$. As $$$w_2 \leq w_6$$$, the value of $$$w_2$$$ is left unchanged. Remove card $$$6$$$. After this operation, $$$s = [2, 6]$$$.  Select card $$$4$$$. Append $$$w_4 = 2$$$ to the end of $$$s$$$. As $$$w_1 \leq w_4$$$, the value of $$$w_1$$$ is left unchanged. Remove card $$$4$$$. After this operation, $$$s = [2, 6, 2]$$$.  Select card $$$3$$$. Append $$$w_3 = 4$$$ to the end of $$$s$$$. As $$$w_2 > w_3$$$, the value of $$$w_2$$$ becomes $$$4$$$. Remove card $$$3$$$. After this operation, $$$s = [2, 6, 2, 4]$$$.  Select card $$$2$$$. Append $$$w_2 = 4$$$ to the end of $$$s$$$. As $$$w_1 \leq w_2$$$, the value of $$$w_1$$$ is left unchanged. Remove card $$$2$$$. After this operation, $$$s = [2, 6, 2, 4, 4]$$$.  Select card $$$1$$$. Append $$$w_1 = 1$$$ to the end of $$$s$$$. Remove card $$$1$$$. After this operation, $$$s = [2, 6, 2, 4, 4, 1]$$$. One of the longest non-decreasing subsequences of $$$s = [2, 6, 2, 4, 4, 1]$$$ is $$$[2, 2, 4, 4]$$$. Thus, the length of the longest non-decreasing subsequence of $$$s$$$ is $$$4$$$. It can be proven that this is indeed the maximum possible length.


Pak Chanek has a prime number$$$^\dagger$$$ $$$n$$$. Find a prime number $$$m$$$ such that $$$n + m$$$ is not prime.$$$^\dagger$$$ A prime number is a number with exactly $$$2$$$ factors. The first few prime numbers are $$$2,3,5,7,11,13,\ldots$$$. In particular, $$$1$$$ is not a prime number.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The following lines contain the description of each test case. The only line of each test case contains a prime number $$$n$$$ ($$$2 \leq n \leq 10^5$$$).

For each test case, output a line containing a prime number $$$m$$$ ($$$2 \leq m \leq 10^5$$$) such that $$$n + m$$$ is not prime. It can be proven that under the constraints of the problem, such $$$m$$$ always exists. If there are multiple solutions, you can output any of them.

NoteIn the first test case, $$$m = 2$$$, which is prime, and $$$n + m = 7 + 2 = 9$$$, which is not prime.In the second test case, $$$m = 7$$$, which is prime, and $$$n + m = 2 + 7 = 9$$$, which is not prime.In the third test case, $$$m = 47837$$$, which is prime, and $$$n + m = 75619 + 47837 = 123456$$$, which is not prime.


Pak Chanek, a renowned scholar, invented a card puzzle using his knowledge. In the puzzle, you are given a board with $$$n$$$ rows and $$$m$$$ columns. Let $$$(r, c)$$$ represent the cell in the $$$r$$$-th row and the $$$c$$$-th column.Initially, there are $$$k$$$ cards stacked in cell $$$(1, 1)$$$. Each card has an integer from $$$1$$$ to $$$k$$$ written on it. More specifically, the $$$i$$$-th card from the top of the stack in cell $$$(1, 1)$$$ has the number $$$a_i$$$ written on it. It is known that no two cards have the same number written on them. In other words, the numbers written on the cards are a permutation of integers from $$$1$$$ to $$$k$$$. All other cells are empty.You need to move the $$$k$$$ cards to cell $$$(n, m)$$$ to create another stack of cards. Let $$$b_i$$$ be the number written on the $$$i$$$-th card from the top of the stack in cell $$$(n, m)$$$. You should create the stack in cell $$$(n, m)$$$ in such a way so that $$$b_i = i$$$ for all $$$1 \leq i \leq k$$$.In one move, you can remove the top card from a cell and place it onto an adjacent cell (a cell that shares a common side). If the target cell already contains one or more cards, you place your card on the top of the stack. You must do each operation while satisfying the following restrictions:   Each cell other than $$$(1,1)$$$ and $$$(n,m)$$$ must not have more than one card on it.  You cannot move a card onto cell $$$(1,1)$$$.  You cannot move a card from cell $$$(n,m)$$$. Given the values of $$$n$$$, $$$m$$$, $$$k$$$ and the array $$$a$$$, determine if the puzzle is solvable.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 2 \cdot 10^4$$$) — the number of test cases. The following lines contain the description of each test case. The first line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$3 \leq n, m \leq 10^6$$$, $$$nm \leq 10^6$$$, $$$1 \leq k \leq 10^5$$$) — the size of the board and the number of cards. The second line of the test case contains $$$k$$$ integers $$$a_1, a_2, \ldots, a_k$$$ — the array $$$a$$$, representing the numbers written on the cards. The values of $$$a$$$ are a permutation of integers from $$$1$$$ to $$$k$$$. It is guaranteed that the sum of $$$nm$$$ and $$$k$$$ over all test cases do not exceed $$$10^6$$$ and $$$10^5$$$ respectively.

For each test case, output "YA" (without quotes) if it is possible and "TIDAK" (without quotes) otherwise, which mean yes and no in Indonesian respectively. You can output "YA" and "TIDAK" in any case (for example, strings "tiDAk", "tidak", and "Tidak" will be recognised as a negative response).

NoteIn the first test case, the following is one way the puzzle can be done:   Move the card with $$$3$$$ written on it from cell $$$(1, 1)$$$ to cell $$$(1, 2)$$$, then cell $$$(1, 3)$$$.  Move the card with $$$6$$$ written on it from cell $$$(1, 1)$$$ to cell $$$(2, 1)$$$, then cell $$$(3, 1)$$$, then cell $$$(3, 2)$$$, then cell $$$(3, 3)$$$.  Move the card with $$$4$$$ written on it from cell $$$(1, 1)$$$ to cell $$$(1, 2)$$$.  Move the card with $$$1$$$ written on it from cell $$$(1, 1)$$$ to cell $$$(2, 1)$$$, then cell $$$(2, 2)$$$, then cell $$$(2, 3)$$$.  Move the card with $$$2$$$ written on it from cell $$$(1, 1)$$$ to cell $$$(2, 1)$$$, then cell $$$(2, 2)$$$.  Move the card with $$$5$$$ written on it from cell $$$(1, 1)$$$ to cell $$$(2, 1)$$$, then cell $$$(3, 1)$$$, then cell $$$(3, 2)$$$, then cell $$$(3, 3)$$$.  Move the card with $$$2$$$ written on it from cell $$$(2, 2)$$$ to cell $$$(2, 1)$$$.  Move the card with $$$4$$$ written on it from cell $$$(1, 2)$$$ to cell $$$(2, 2)$$$, then cell $$$(3, 2)$$$, then cell $$$(3, 3)$$$.  Move the card with $$$3$$$ written on it from cell $$$(1, 3)$$$ to cell $$$(1, 2)$$$, then cell $$$(2, 2)$$$, then cell $$$(3, 2)$$$, then cell $$$(3, 3)$$$.  Move the card with $$$2$$$ written on it from cell $$$(2, 1)$$$ to cell $$$(3, 1)$$$, then cell $$$(3, 2)$$$, then cell $$$(3, 3)$$$.  Move the card with $$$1$$$ written on it from cell $$$(2, 3)$$$ to cell $$$(3, 3)$$$. An animated illustration regarding the process mentioned above is as follows:


Pak Chanek is given an array $$$a$$$ of $$$n$$$ integers. For each $$$i$$$ ($$$1 \leq i \leq n$$$), Pak Chanek will write the one-element set $$$\{a_i\}$$$ on a whiteboard.After that, in one operation, Pak Chanek may do the following:   Choose two different sets $$$S$$$ and $$$T$$$ on the whiteboard such that $$$S \cap T = \varnothing$$$ ($$$S$$$ and $$$T$$$ do not have any common elements).  Erase $$$S$$$ and $$$T$$$ from the whiteboard and write $$$S \cup T$$$ (the union of $$$S$$$ and $$$T$$$) onto the whiteboard. After performing zero or more operations, Pak Chanek will construct a multiset $$$M$$$ containing the sizes of all sets written on the whiteboard. In other words, each element in $$$M$$$ corresponds to the size of a set after the operations.How many distinct$$$^\dagger$$$ multisets $$$M$$$ can be created by this process? Since the answer may be large, output it modulo $$$998\,244\,353$$$.$$$^\dagger$$$ Multisets $$$B$$$ and $$$C$$$ are different if and only if there exists a value $$$k$$$ such that the number of elements with value $$$k$$$ in $$$B$$$ is different than the number of elements with value $$$k$$$ in $$$C$$$.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).

Output the number of distinct multisets $$$M$$$ modulo $$$998\,244\,353$$$.