2025-2026 Whitney Young Practice Contest 1
A. An Unfortunate Coincidence
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

SnowballSH really enjoyed his time at Whitney M. Young Magnet High School, so much that he often wears his Whitney Young Math Team merch even at Carnegie Mellon University.

Unfortunately, the letters "WY" on these shirts and jackets could refer to both Whitney Young and the state of Wyoming. As a result, many people have come up to SnowballSH and asked him if he is from Wyoming.

To solve this problem, SnowballSH wishes to create a program that, when given a list of $$$n$$$ words, automatically converts all instances of "WY" to "Whitney Young". Can you help him?

Input

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

Then, $$$n$$$ lines follow. The $$$i$$$-th line contains a string $$$s_i$$$ $$$(1 \le |s_i| \le 67)$$$ — the $$$i$$$-th word.

It is guaranteed that for all $$$i=1,2,\dots,n$$$, $$$s_i$$$ contains only lowercase and uppercase Latin alphabets.

Output

For each of the $$$n$$$ words, on a separate line, output Whitney Young if $$$s_i = $$$ WY (case-sensitive). Otherwise, output $$$s_i$$$ as it is.

Example
Input
9
I
miss
WY
Math
Team
and
WY
Coding
Club
Output
I
miss
Whitney Young
Math
Team
and
Whitney Young
Coding
Club

B. Born to be Here
time limit per test
0.6 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

In late January 2020, SnowballSH arrived in Chicago just a few days before international flights were cancelled. In 2021, he decided to attend Whitney M. Young Magnet High School after missing the Northside cutoff by exactly one point. Perhaps he was destined to be here?

SnowballSH loves the string "WY".

Given a string $$$s$$$ of length $$$n$$$, please help SnowballSH count the number of ordered pairs $$$(i, j)$$$, where $$$1 \le i \lt j \le n$$$, such that $$$s_i =$$$ W and $$$s_j =$$$ Y.

Input

The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^6$$$).

The second line contains a string $$$s$$$ of length $$$n$$$.

It is guaranteed that $$$s$$$ contains only uppercase Latin alphabets.

Output

Output a single integer, the number of ordered pairs $$$(i, j)$$$, where $$$1 \le i \lt j \le n$$$, such that $$$s_i =$$$ W and $$$s_j =$$$ Y.

Examples
Input
20
WYMATHTEAMNOTWYOMING
Output
3
Input
21
YWWYYYWWWWYYYYYWWWWWW
Output
36
Note

For the first test, the desired pairs are $$$(1,2)$$$, $$$(1,15)$$$, and $$$(14,15)$$$, so the answer is $$$3$$$.

C. Classroom
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Antares's classroom has $$$k$$$ seats that lie uniformly on a circle, labelled $$$1, 2, \dots, k$$$ in clockwise order.

In a particular class, he has $$$n$$$ students, each sitting in one of the $$$k$$$ seats. Each student occupies exactly one seat, and no two students share the same seat. Antares has an array $$$a$$$ of length $$$n$$$, which serves as a seating chart for the class, where student $$$i$$$ is sitting in the seat labelled $$$a_i$$$ for each $$$i=1,2,\dots,n$$$.

Antares recently realized that his students only talk to classmates sitting close to them. This is not good! Because of this, he wants to encourage students to talk to classmates who sit far away.

To do this, he wants to pick a pair of students such that the distance between the two students he picks is the greatest among the distances between any pair of two students.

The distance between two students is the minimum number of seats one needs to pass to reach the other, walking clockwise or counter-clockwise around the circle, including the destination seat (but not including the starting seat).

Please help Antares find two such students.

Input

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of test cases.

The first line of each test case contains two integers $$$n$$$ and $$$k$$$ $$$(2 \le n \le 10^5, n \le k \le 10^9)$$$ — the number of students in the class and the number of seats in the class, respectively.

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ $$$(1 \le a_i \le k)$$$, indicating student $$$i$$$ is sitting in the seat labelled $$$a_i$$$. All values of $$$a_i$$$ are distinct.

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

Output

For each test case, output two integers $$$i$$$ and $$$j$$$, indicating Antares should pick students $$$i$$$ and $$$j$$$. If there are multiple answers, output any of them.

Example
Input
4
4 7
7 3 5 2
3 8
1 6 3
2 2
1 2
5 10000
1 10 100 1000 10000
Output
3 4
2 1
1 2
5 4
Note

Let $$$d(x,y)$$$ denote the distance between students $$$x$$$ and $$$y$$$.

For the first test case, we have the following classroom:

We have $$$d(1,2)=3$$$, $$$d(1,3)=2$$$, $$$d(1,4)=2$$$, $$$d(2,3)=2$$$, $$$d(2,4)=1$$$, $$$d(3,4)=3$$$. Since the largest distance is $$$3$$$, Antares can pick students $$$3$$$ and $$$4$$$. For this test case, 1 2 is also acceptable.

D. Distance Indicators
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

SnowballSH recently learned $$$n$$$ new words in Japanese. To enhance his learning, he wants to develop a method to determine the similarity between any two words.

To start, for each $$$i=1,2,\dots,n$$$, SnowballSH gives each word $$$i$$$ a positive integer score $$$a_i$$$.

Given two indices $$$i$$$ and $$$j$$$ $$$(1 \le i \lt j \le n)$$$, SnowballSH defines the distance between words $$$i$$$ and $$$j$$$ as $$$$$$\mathrm{dist}(i,j) = a_i + a_j.$$$$$$

To measure how well this function represents the order in which he learned the new words, SnowballSH calls an ordered pair $$$(i, j)$$$ $$$(1 \le i \lt j \le n)$$$ beautiful if and only if $$$$$$j - i = \mathrm{dist}(i,j).$$$$$$

Please help SnowballSH determine the number of beautiful pairs.

Input

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of test cases.

The first line of each test case contains an integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the number of words SnowballSH has learned.

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ $$$(1 \le a_i \le 2 \cdot 10^5)$$$, indicating word $$$i$$$ has score $$$a_i$$$.

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

Output

For each test case, output the number of ordered pairs $$$(i, j)$$$ where $$$1 \le i \lt j \le n$$$ such that $$$(i, j)$$$ is beautiful.

Example
Input
3
9
3 1 4 1 5 9 2 6 5
3
2025 2025 2025
13
2 7 1 8 2 8 1 8 2 8 4 5 9
Output
3
0
5
Note

For test case 1:

For example, when $$$(i,j)=(4,7)$$$, we have $$$j-i=7-4=3$$$ and $$$\mathrm{dist}(i,j)=a_i+a_j=1+2=3$$$, so $$$(4,7)$$$ is beautiful.

Only the three pairs $$$(i,j)=(1,9),(2,4),(4,7)$$$ are beautiful, so output 3.

E. Eureka!
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

This is an interactive problem.

The king has received $$$n$$$ chests, one from each of $$$n$$$ neighboring empires. Each chest contains exactly $$$m$$$ ($$$m \ge n$$$) identical-looking nuggets.

The king's advisor reveals that exactly one of these chests is filled with only counterfeit nuggets, while the remaining $$$n-1$$$ chests contain only real gold.

Each real gold nugget weighs $$$r$$$ grams (where $$$r \ge 2$$$), and each counterfeit nugget weighs $$$f$$$ grams (where $$$1 \le f \lt r$$$).

You have access to a single, precise balance scale. You can take any number of nuggets from each chest and place them on the scale to find their total combined weight. However, the scale is a delicate prototype and can be used at most once before it breaks.

As the royal scientist, you must identify which empire sent the counterfeit chest.

Input

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \le t \le 1000)$$$ — the number of test cases. The description of test cases follows.

The only line contains four integers $$$n, m, r, f$$$ $$$(1 \le n \le 10^4, n \le m \le 10^5, 1 \le f \lt r \le 10^5)$$$ — the number of chests, the number of nuggets in each chest, the weight of each real nugget, and the weight of each fake nugget, respectively.

It is guaranteed that the sum of $$$n$$$ overall test cases is not greater than $$$10^4$$$.

Interaction

To make a measurement, output ? followed by $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le m$$$ for $$$i = 1,2,\dots,n$$$), where $$$a_i$$$ represents the number of nuggets from the chest from empire $$$i$$$ you wish to put on the balance.

In response to this measurement, you will receive the total weight of the $$$\sum_{i=1}^n a_i$$$ nuggets on the balance. Remember that you may take at most one measurement. If you make more than one measurement, you will receive the Wrong Answer verdict.

To output the answer, output ! $$$i$$$ ($$$1 \le i \le n$$$), indicating that you believe empire $$$i$$$ sent the chest of fake nuggets.

After outputting a query, do not forget to output a newline and flush the output buffer. Otherwise, you will receive the verdict Idleness limit exceeded. To flush the buffer, use:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see the documentation for other languages.
Examples
Input
1
5 5 5 4

55
Output
? 4 2 0 3 2

! 3
Input
2
1 100 10000 101
3 6 1000 999

12999
Output
! 1

? 1 6 6

! 1
Note

In the first example, there are 5 empires, each having sent a chest of 5 nuggets. Each real nugget weighs 5 grams, and each fake nugget weighs 4 grams. In the example, we asked to weigh 4 nuggets from the first empire's chest, 2 from the second's, none from the third's, 3 from the fourth's, and 2 from the fifth's. The interactor tells us the total weight to be 55. Since none of our choice of quantity is a multiple of 5 except 0, but 55 is a multiple of 5, empire 3 must have sent us the chest of 4-gram nuggets.

In the first test case of the second example, since there is only one empire, it must have sent the chest of fake gold.

F. Finding Shelters
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

At Carnegie Mellon University, there are often many automatic water sprayers placed on campus to water the grass.

Unfortunately, SnowballSH often gets showered (or, as he often says, attacked) by these water sprayers while casually walking to class through a piece of grass referred to as "The Mall."

The Mall can be represented by an $$$m \times n$$$ rectangular grid, with $$$k$$$ of its cells containing an automatic water sprayer.

Each automatic water sprayer can be modeled to be continuously showering all cells in its row and all cells in its column.

A cell is called safe if and only if it is not showered by any automatic water sprayer.

Please help SnowballSH determine the number of safe cells on The Mall.

Input

The first line contains three integers $$$m$$$, $$$n$$$, and $$$k$$$ ($$$1 \le m \le 1500$$$, $$$1 \le n \le 1500$$$, $$$0 \le k \le mn$$$) — the number of rows, the number of columns, and the number of automatic water sprayers.

The $$$i$$$-th line of each of the following $$$k$$$ lines contains two integers $$$r_i$$$ and $$$c_i$$$ ($$$1 \le r_i \le m$$$, $$$1 \le c_i \le n$$$) — the row and column of the location of the $$$i$$$-th automatic water sprayer, respectively.

It is guaranteed that $$$(r_i, c_i) \ne (r_j, c_j)$$$ for all $$$i \ne j$$$.

Output

Output a single integer — the number of safe squares on the grid.

Examples
Input
6 7 5
2 2
3 3
2 5
6 7
5 5
Output
6
Input
1 100 1
1 67
Output
0
Input
15 135 0
Output
2025
Note

For the first test case, we have the following grid, where the circles represent cells with automatic water sprayers and blue diamonds represent safe cells:

There are six safe cells, so the answer is $$$6$$$.

For the second test case, there are no safe cells.

For the third test case, there are no automatic water sprayers, so all cells are safe.

G. Graph and Information Delivery
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

SnowballSH has installed $$$n$$$ computers and wants to transmit information between them.

With one wire, SnowballSH can connect two computers. When a computer receives some information, it will automatically transmit it to all computers connected to it by a wire in exactly $$$1$$$ second.

SnowballSH wants to make sure that it is possible to deliver information from any computer to every other computer in at most $$$k$$$ seconds. However, he also wants to minimize the number of wires he needs to buy.

Please help SnowballSH determine the minimum number of wires he needs.

Input

Each test contains multiple test cases. The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases.

The first (and only) line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n, k \le 10^9$$$) — the number of computers and the maximum allowed time for information on a computer to reach every other computer.

Output

For each test case, print one integer — the minimum number of wires SnowballSH needs.

Example
Input
3
3 1
5 3
1 1000000000
Output
3
4
0
Note

For the first test case, SnowballSH can use three wires to connect computer 1 and computer 2, computer 2 and computer 3, and computer 3 and computer 1. It can be shown that it is not possible to transmit information from any computer to any other computer in at most $$$1$$$ second using less than $$$3$$$ wires.

H. Hunting Down Binary Numbers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Given positive integers $$$l$$$ and $$$x$$$, help SnowballSH find two integers $$$a$$$ and $$$b$$$ such that:

  • $$$l \le a \le b \le 10^{18}$$$, and
  • $$$\mathrm{popcount}(a \oplus b) = x$$$.$$$^{\text{∗}}$$$$$$^{\text{†}}$$$

$$$^{\text{∗}}$$$The bitwise XOR of non-negative integers $$$x$$$, $$$y$$$, $$$x \oplus y$$$, is defined as follows:

When $$$x \oplus y$$$ is written in binary, the digit in the $$$2^k$$$ ($$$k \ge 0$$$) place is $$$1$$$ if exactly one of $$$x,y$$$ has $$$1$$$ in the $$$2^k$$$ place when written in binary, and $$$0$$$ otherwise.

For example, $$$3 \oplus 5 = 6$$$ (in binary representation: $$$011 \oplus 101=110$$$).

$$$^{\text{†}}$$$$$$\mathrm{popcount}(x)$$$ represents the number of $$$1$$$s in the binary representation of $$$x$$$.

For example, $$$13=1101_{(2)}$$$, so $$$\mathrm{popcount}(13)=3$$$.

Input

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of test cases.

The only line of each test case contains two integers $$$l$$$ and $$$x$$$ $$$(1 \le l \le 10^{17}, 1 \le x \le 59)$$$.

Output

Output two integers $$$a$$$ and $$$b$$$ such that $$$l \le a \le b \le 10^{18}$$$ and $$$\mathrm{popcount}(a \oplus b) = x$$$.

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

It can be shown that an answer always exists.

Example
Input
3
1 1
2 2
15 3
Output
6 7
2 22
20 25
Note

For the first test case, we have $$$l=1$$$ and $$$x=1$$$. $$$a=6$$$ and $$$b=7$$$ works, because $$$1 \le 6 \le 7 \le 10^{18}$$$ and $$$\mathrm{popcount}(6 \oplus 7) = \mathrm{popcount}(1) = 1$$$.

For the second test case, we have $$$l=2$$$ and $$$x=2$$$. $$$a=2$$$ and $$$b=22$$$ works, because $$$1 \le 2 \le 22 \le 10^{18}$$$ and $$$\mathrm{popcount}(2 \oplus 22) = \mathrm{popcount}(20) = \mathrm{popcount}(10100_{(2)}) = 2$$$.

For the third test case, we have $$$l=15$$$ and $$$x=3$$$. $$$a=20$$$ and $$$b=25$$$ works, because $$$15 \le 20 \le 25 \le 10^{18}$$$ and $$$\mathrm{popcount}(20 \oplus 25) = \mathrm{popcount}(13) = \mathrm{popcount}(1101_{(2)}) = 3$$$.

I. Imaginary Dance Moves
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

SnowballSH is standing on a linear dance machine with $$$n$$$ squares in a row. By the rules, SnowballSH must move either left or right exactly one square every move. Initially, his score is $$$0$$$. Each square has a bonus value, and his final score is the sum of the bonus values of all the squares he has stepped on. Some squares have a negative bonus value, which means SnowballSH gets a penalty for stepping on there!

SnowballSH is currently standing at the $$$k-$$$th square from the left. Unfortunately, SnowballSH prepared his dance moves $$$s$$$ last night but forgot some of them. Help SnowballSH figure out the maximum score he could get after $$$|s|$$$ moves, if each missing dance move is replaced by either left or right.

Note that the initial square does not count towards the final score. If SnowballSH attempts to move left at the leftmost square, he will step on that square again, gaining its bonus. Similarly, if he attempts to move right at the rightmost square, he will step on that square again, gaining its bonus.

Input

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \le t \le 1000)$$$ — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ $$$(2 \le n \le 1000)$$$ and $$$k$$$ $$$(1 \le k \le n)$$$ — the number of squares on the machine and the position of SnowballSH's initial position, respectively. The leftmost square has position $$$1$$$ and the rightmost square has position $$$n$$$.

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(-10^5 \le a_i \le 10^5)$$$ — the bonus value for each square.

The third line of each test case contains a string $$$s$$$ $$$(1 \le |s| \le 2000)$$$, the dance moves SnowballSH will perform. A missing dance move will be denoted as a ?, a left move will be denoted as L, and a right move will be denoted as R. These are the only three characters that could appear in $$$s$$$.

It is guaranteed that both the sum of $$$n$$$ and the sum of $$$|s|$$$ over all test cases are not greater than $$$2000$$$.

Output

For each test case, print a single integer — the maximum score SnowballSH could get by replacing each ? with an L or R.

Example
Input
4
5 3
3 5 8 2 3
LRLLLL
7 5
-7 0 3 15 1 -6 9
?RL??LRRR
4 1
1 -100 -200 800
????L
8 8
1 2 3 9 6 3 2 1
??L?RR????RR?
Output
27
62
1100
74
Note

For the first test case, SnowballSH didn't forget any dance move, so he starts at $$$8$$$ (position $$$3$$$) and goes to $$$5, 8, 5, 3, 3, 3$$$ in order. His score is $$$5 + 8 + 5 + 3 + 3 + 3 = 27$$$.

For the second test case, SnowballSH starts at $$$1$$$ (position $$$5$$$). He can complete the dance moves as LRLLRLRRR to achieve a maximum score of $$$15 + 1 + 15 + 3 + 15 + 3 + 15 + 1 - 6 = 62$$$.

The moves for test cases 3 and 4 are RRRRL and LLLLRRLLRLRRL, respectively.

J. Jaywalking
time limit per test
1 second
memory limit per test
32 megabytes
input
standard input
output
standard output

Parallel sidewalks $$$A$$$ and $$$B$$$ of length $$$n$$$ units are separated by a road. There are also $$$m$$$ crosswalks with traffic lights connecting the two sidewalks. All $$$m$$$ lights are in sync, and they are all green as SnowballSH arrives at location $$$1$$$ unit of sidewalk $$$A$$$ at time $$$t=0$$$. However, the light colors alternate every $$$k$$$ seconds. For example, the lights are green on seconds $$$t=0,1,\dots,k-1$$$, red on seconds $$$t=k,k+1,\dots,2k-1$$$, and then green again on seconds $$$t=2k,2k+1,\dots,3k-1$$$, etc.

SnowballSH needs to get to location $$$n$$$ unit of sidewalk $$$B$$$ by crossing the road at one of the crosswalks. At each second, SnowballSH may perform one of the following actions:

  • Walk forward $$$1$$$ unit on the current crosswalk.
  • If there is a crosswalk at SnowballSH's location and the light is green, cross the road to the other sidewalk, without moving forward.
  • Do nothing and wait at his current location.

After his action, the time advances by one second.

Please help SnowballSH determine the fastest possible time he can arrive at location $$$n$$$ on sidewalk $$$B$$$.

Input

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of test cases.

The first line of each test case contains three integers $$$n, m, k$$$ ($$$1 \le m \le n \le 10^5$$$; $$$1 \le k \le 10^9$$$) — the length of the sidewalks, the number of crosswalks, and the number of seconds before the light colors alternate, respectively.

The second line contains $$$m$$$ integers $$$c_1, c_2, \dots, c_m$$$, indicating there is a crosswalk at location $$$c_i$$$ unit for each $$$i=1,2,\dots,m$$$.

Output

For each test case, print one integer — the minimum number of seconds SnowballSH needs to arrive at location $$$n$$$ on sidewalk $$$B$$$.

Example
Input
3
6 2 1
2 5
12 3 5
9 6 8
1234 1 123
666
Output
6
14
1307
Note

For the first test case, there are two possible crosswalks SnowballSH can take:

  • Take the crosswalk at location $$$2$$$ units. Then, he needs to walk for $$$2-1=1$$$ second, wait $$$1$$$ second for the light to change to green, spend $$$1$$$ second crossing, and then spend $$$6-2=4$$$ more seconds walking. Therefore, he needs a total of $$$7$$$ seconds.
  • Take the crosswalk at location $$$5$$$ units. Then, he needs to walk for $$$5-1=4$$$ seconds, spend $$$1$$$ second crossing, and then spend $$$6-5=1$$$ more second walking. Therefore, he needs a total of $$$6$$$ seconds.

Overall, SnowballSH should take the second crosswalk. It can be shown that it is not possible for SnowballSH to take less than $$$6$$$ seconds.

For the third test case, there is only one crosswalk SnowballSH can take. The light turns red at $$$t=123\times 5=615$$$ seconds and turns green again at $$$t=123\times 6=738$$$ seconds. Since SnowballSH arrives at the crosswalk at $$$t=666-1=665$$$, he needs to wait $$$738-665=73$$$ seconds. The time SnowballSH needs is therefore $$$(666-1)+73+1+(1234-666)=1307$$$ seconds.

K. Kaneiji Meilong Robotics
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The Robotics Institute at Carnegie Mellon University has a linear obstacle course of length $$$n$$$. The heights of the obstacles are described by an integer array $$$a$$$, where $$$a_i$$$ denotes the height of the obstacle at location $$$i$$$. In particular, if $$$a_i = 0$$$, then there is no obstacle at location $$$i$$$.

With a budget of $$$d$$$ dollars, SnowballSH can choose a nonnegative integer $$$h_{\mathrm{init}} \le d$$$ and construct a robot of height $$$h_{\mathrm{init}}$$$. Then, his robot will go through the obstacle course in the following manner: for each $$$i=1,2,\dots,n$$$, when the robot encounters an obstacle with value $$$a_i \gt 0$$$, one of the two possibilities happens:

  • If the current height of the robot $$$h$$$ is less than $$$a_i$$$, then nothing happens, since the robot is shorter than the obstacle.
  • If the current height of the robot $$$h$$$ is at least $$$a_i$$$, then the new height changes to $$$h' = h - a_i$$$.

Please help SnowballSH determine the maximum possible height which the robot can end up at after running through the obstacle course over all $$$0 \le h_{\mathrm{init}} \le d$$$.

Input

The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le n \le 10^6$$$, $$$1 \le d \le 10^9$$$) — the length of the obstacle course and SnowballSH's budget, respectively.

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$) — the description of the obstacle course.

Output

Output a single integer — the answer to the problem.

Examples
Input
5 5
0 2 6 1 3
Output
2
Input
7 10
7 6 2 5 0 1 4
Output
2
Input
11 1000
3 1 4 1 5 9 2 6 5 3 5
Output
956

L. Lovely Perfect Right Triangles
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

SnowballSH has learned from his math teacher that a right triangle is a triangle with a $$$90^\circ$$$ angle, and a perfect square is a positive integer that is also the square of a positive integer.

Combining these ideas, SnowballSH calls a right triangle perfect if and only if

  • its three side lengths are all positive integers,
  • its three side lengths share no common factor other than 1, and
  • the arithmetic mean of its shortest side and its longest side is a perfect square.

SnowballSH gives you a positive integer $$$n$$$. Please help him determine the number of non-congruent$$$^{*}$$$ perfect right triangles whose side lengths are all at most $$$n$$$.

$$${}^*$$$ Two triangles are non-congruent if and only if there exists no sequence of translation, rotation, and/or reflection that maps one triangle exactly onto the other.

Input

Each test consists of several test cases. The first line contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$), the number of test cases. The description of the test cases follows.

The only line of each test case contains a positive integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^7$$$) — the maximum side length for a triangle.

Note that there is no constraint on the sum of $$$n$$$ over all test cases.

Output

For each test case, output a single integer — the number of non-congruent perfect triangles whose side lengths are all at most $$$n$$$.

Example
Input
4
1
5
20
100
Output
0
1
2
9
Note

For the first test case, all three sides of the triangle must have length 1, which means the triangle cannot be a right triangle.

For the third test case, the two perfect triangles have side lengths 3–4–5 and 5–12–13. We can check that they are both right triangles, the side lengths share no common factor other than 1 for each of the triangles, and $$$\frac{3+5}{2}=4=2^2$$$, $$$\frac{5+13}{2}=9=3^2$$$ are both perfect squares. Note that 8–15–17 is not a perfect triangle because $$$\frac{8+17}{2}=12.5$$$ is not a perfect square. It can be shown that there exist no other perfect triangles with side lengths all at most 20. Therefore, the answer is 2.