Intra-IUT Junior Programming Contest (IJPC) 2026
A. Glorious Batch-24!
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Batch-24 is hosting a "Pre-IUT Meetup" at Smashed Burgers. As part of the registration process, the organizers created registration forms with unique form IDs starting from $$$1$$$ and increasing sequentially.

When registration ended, the organizers found that the number of submissions greatly exceeded the actual number of students in their batch. After the investigation, they discovered that impostors from other batches had also filled out the forms. They examined a few impostor entries and were relieved to find a pattern. An entry is made by an impostor if for the form ID $$$x$$$, $$$x^2 - 1 \text{ is divisible by 24} \quad \text{i.e.,} \quad (x^2 - 1) \equiv 0 \pmod{24}.$$$

Your task is to count the total number of impostors among the first $$$N$$$ form submissions to maintain the Glory of 24!

Input

The first line of the input contains a single integer $$$T$$$ ($$$1 \leq T \leq 10^5$$$) — the number of test cases.

Each test case consists of a single line containing a single integer $$$N$$$ ($$$1 \leq N \leq 10^{18}$$$) — the total number of forms submitted.

Output

For each test case, output a single integer in a line — the number of impostors.

Example
Input
4
1
9
13456
100000000
Output
1
3
4485
33333333

B. XORnacci
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given the first $$$m$$$ elements of an infinite sequence $$$a_1, a_2, \ldots, a_m$$$.

For every index $$$i \gt m$$$, the sequence is extended according to the following rule: $$$$$$ a_i = a_{i-2} \oplus a_{i-1}, $$$$$$ where $$$\oplus$$$ denotes the bitwise XOR operation.

Your task is to determine the value of $$$a_1 \oplus a_2 \oplus \cdots \oplus a_n$$$, that is, the bitwise XOR of the first $$$n$$$ elements of the sequence.

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 space-separated integers $$$n$$$ and $$$m$$$ ($$$2 \le m \le n$$$, $$$m \le 2 \times 10^5$$$, $$$n \le 10^9$$$).

The second line of each test case contains $$$m$$$ space-separated integers $$$a_1, a_2, \ldots, a_m$$$ ($$$0 \le a_i \lt 2^{30}$$$) — the first $$$m$$$ elements of the sequence.

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

Output

For each test case, output a single integer in a line – the bitwise XOR of the first $$$n$$$ elements of the sequence.

Example
Input
3
5 4
1 2 3 4
8 3
3 5 14
100 2
0 0
Output
3
6
0
Note

In the first test case, $$$a_5 = a_4 \oplus a_3 = 4 \oplus 3 = 7$$$. So, the bitwise XOR of the first $$$5$$$ elements of the sequence is $$$1 \oplus 2 \oplus 3 \oplus 4 \oplus 7 = 3$$$.

In the third test case, all the elements in the sequence are $$$0$$$, and so the bitwise XOR of the first $$$100$$$ elements is also $$$0$$$.

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

Zunaid is notoriously forgetful. To make his life easier, he always sets his computer password using a combination of his favorite digits: $$$0$$$ and $$$d$$$. He usually sticks to predictable, simple patterns—like a sequence of $$$d$$$s followed by some $$$0$$$s (e.g., $$$dddd0000$$$), or simple repeating arrangements that his forgetful mind can easily retrace (e.g., $$$dd00dd$$$ or $$$d0d0d0$$$).

His roommate, Imtiaz, considers himself a bit of a detective. He has spent months "studying" Zunaid's habits and has successfully cracked the password dozens of times. On a particularly chilly winter night, Zunaid decided he'd had enough. He set a new password, stood by the door, and smirked at Imtiaz.

"I'm heading over to CDS for a bit. I've set a password so strong that you can never deduce it. If you can crack it before I return, I'll treat you to an IUTian's Pizza tomorrow. If not, you owe me."

The inner detective in Imtiaz couldn't refuse. As soon as the door clicked shut, he pulled out a cheap UV flashlight. Shining it over the keypad, he saw deep, glowing marks only on the $$$0$$$ and $$$d$$$ keys, just as he had suspected. He noticed a hint on the lock screen: "Divisible by $$$n$$$." He also knew a password could consist of at most $$$n$$$ digits.

Luck wasn't on Imtiaz's side. Zunaid returned much earlier than expected. However, Imtiaz confidently claimed he had already deduced the password's logic and surely could have cracked it if he had been given five more minutes. Hearing his deductions, Zunaid laughed and replied, "Deducing the properties was the easy part! I'll still buy the pizza if you can actually give me any positive integer that follows the properties:"

  • Consists only of digits $$$0$$$ and $$$d$$$.
  • Is divisible by $$$n$$$.
  • Has a length of at most $$$n$$$ digits.
  • Does not contain any leading zero

Time is running out. Can you help Imtiaz get the free pizza?

Input

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

Each test case consists of a single line containing two integers $$$n$$$ and $$$d$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le d \le 9$$$).

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. For each test case, it is guaranteed that at least one such positive integer exists.

Output

For each test case, output a positive integer in a line that consists only of the digits $$$0$$$ and $$$d$$$, is divisible by $$$n$$$, contains no leading zero and has a length that does not exceed $$$n$$$.

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

Example
Input
3
6 4
9 3
6 3
Output
4440
333333333
303330
Note

In the first test case, $$$n = 6$$$ and $$$d = 4$$$. The output $$$4440$$$ is a positive integer of length $$$4 \le 6$$$. It consists only of $$$4$$$ and $$$0$$$, and it is divisible by $$$6$$$.

In the second test case, $$$n = 9$$$ and $$$d = 3$$$. The output $$$333333333$$$ consists only of the digit $$$3$$$. Its length is $$$9 \le 9$$$, and it is divisible by $$$9$$$.

In the third test case, $$$n = 6$$$ and $$$d = 3$$$. The output $$$303330$$$ is a positive integer of length $$$6 \le 6$$$. It consists only of $$$3$$$ and $$$0$$$, and is divisible by $$$6$$$.

D. Glass Bridge
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

There are $$$N$$$ players participating in a game involving a glass bridge. The bridge consists of $$$M$$$ steps, and each step has two glass panels: one is safe, and the other is fragile and will break if stepped upon.

The players cross the bridge one at a time, following their position in a queue from $$$1$$$ to $$$N$$$. The rules are as follows:

  • Players must cross the bridge in the sequence of their queue positions ($$$1, 2, \dots, N$$$).
  • Each step $$$i$$$ has one safe panel and one fragile panel.
  • When a player's turn comes, they start from step $$$1$$$ and move forward.
  • If a player reaches a step that was previously cleared by a predecessor, they simply step on the known safe panel and continue.
  • If a player reaches a step $$$i$$$ that has not been successfully crossed yet:
    • They must choose one of the two panels.
    • If they choose the fragile panel, they are eliminated. Their turn ends, and the next player in the queue begins their attempt from step $$$1$$$, now knowing which panel at step $$$i$$$ is the safe one.
    • If they choose the safe panel, they proceed to step $$$i+1$$$.
  • The game ends immediately when a player successfully lands on the safe panel of the $$$M$$$-th step. That player is the sole winner.

Every player is rational and will use all information revealed by previous players. If a player reaches a step where the safe panel is unknown, they will choose one of the two panels with a $$$50\%$$$ probability of success.

You have the chance to bribe the organizers to pick any starting position from $$$1$$$ to $$$N$$$. Your goal is to choose the position $$$k$$$ that maximizes your probability of being the sole winner. If multiple positions yield the same maximum probability, choose any such $$$k$$$.

Input

The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of test cases.

Each test case consists of a single line containing two integers:

  • $$$N$$$ ($$$1 \le N \le 2 \cdot 10^5$$$) — total number of players.
  • $$$M$$$ ($$$1 \le M \le 2 \cdot 10^5$$$) — number of steps on the bridge.
Output

For each test case, output a single integer — the optimal position $$$k$$$ ($$$1 \le k \le N$$$) to maximize your winning probability.

Example
Input
3
1 1
2 2
3 3
Output
1
2
3
Note

The following diagram illustrates the glass bridge for the second test case:

For the second test case, if you start at position $$$1$$$ in the queue, then you must correctly choose the safe panel on both steps. Since each unknown step has a success probability of $$$1/2$$$, your probability of winning is:

$$$$$$ \frac{1}{2} \times \frac{1}{2} = \frac{1}{4} = 25\%. $$$$$$

However, if you start at position $$$2$$$, there are two cases where you win:

  • The first player fails on the first step with probability $$$1/2$$$. In this case, the safe panel of the first step becomes known, and you only need to correctly guess the second step. Therefore, your probability of winning in this scenario is: $$$$$$ \frac{1}{2} \times \frac{1}{2} = \frac{1}{4}. $$$$$$

  • The first player successfully crosses the first step and then fails on the second step with probability: $$$$$$ \frac{1}{2} \times \frac{1}{2} = \frac{1}{4}. $$$$$$ In this case, both safe panels become known, so you win with probability $$$1$$$. Therefore, your probability of winning in this scenario is: $$$$$$ \frac{1}{4} \times 1 = \frac{1}{4}. $$$$$$

Hence, the total probability of winning when starting at position $$$2$$$ is:

$$$$$$ \frac{1}{4} + \frac{1}{4} = \frac{1}{2} = 50\%. $$$$$$

E. AutoCAD Mayhem
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

It was the first AutoCAD lab for the first-year students at Irony University of Technology.

Labib and his friend Jehad were sitting side by side. The lab task was simple: draw a triangle using the given line measurements. Excited to finish the task quickly, they were racing each other instead of listening to the instructor.

Confident in their abilities, both of them ignored the tutorial completely and drew their own triangles much faster than the others.

A few minutes later, panic struck.

Neither of them remembered the actual measurements from the instructions, so they had no idea whether their drawings were correct. But instead of checking the lab sheet like normal students, they became curious about something much more interesting:

"By pure luck, did we draw similar triangles?!"

You are given the three side lengths of both triangles. Determine whether the two triangles are similar*.

*Two triangles with side lengths $$$(a, b, c)$$$ and $$$(d, e, f)$$$ are considered similar if there exists a permutation $$$(x, y, z)$$$ of $$$(d, e, f)$$$ such that

$$$$$$\displaystyle \dfrac{a}{x} = \dfrac{b}{y} = \dfrac{c}{z}$$$$$$

Input

The input consists of a single line containing six space-separated integers $$$a, b, c, d, e, f$$$ ($$$1 \le a, b, c, d, e, f \le 10^9$$$) — $$$(a, b, c)$$$ are the side lengths of Labib's triangle and $$$(d, e, f)$$$ are the side lengths of Jehad's triangle.

Output

Output "YES" if the triangles are similar, "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples
Input
2 3 4 4 6 8
Output
YES
Input
2 3 4 4 6 7
Output
NO

F. Still a Group Project??
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

While doing group projects together in their university life, Meena and Kabir used to dream of opening a vintage-style book-cafe. Years later, their dream is finally coming true. The heart of their cafe is a Shelf, holding $$$n$$$ of their favorite books.

Kabir has just finished unboxing the books into an initial order $$$a$$$. Each book is identified by an ID number; since they have several copies of certain favorites, multiple books may share the same ID.

As always, Meena suggests a game: they win if they can reach their "dream" arrangement $$$b$$$—the one from their university notebooks—by only swapping books that are exactly $$$m$$$ slots apart. Formally, they can choose an index $$$i \le n-m$$$, and swap the books at index $$$i$$$ and $$$i+m$$$. As they sip their coffee and enjoy the quiet atmosphere of their new cafe, they wonder if the IDs on the shelf will allow them to win their game.

Input

The first line of input contains $$$t$$$ ($$$1 \le t \le 10^5$$$), the number of testcases.

The first line of each testcase contains two space-separated integers $$$n$$$ and $$$m$$$ ($$$1 \le m \lt n \le 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the IDs of the books in which Kabir unboxed them.

The third line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 10^9$$$) — the ordered IDs in the dream arrangement $$$b$$$.

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

Output

For each test case, output "YES" if it is possible for them to win, "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples
Input
1
6 2
1 2 3 4 5 6
1 6 3 4 5 2
Output
Yes
Input
4
2 1
5 4
4 5
3 1
5 3 1
3 1 5
11 7
2 5 5 2 5 3 3 4 5 2 1
5 5 2 4 3 2 5 3 5 1 2
4 3
4 3 2 3
4 2 3 3
Output
Yes
Yes
No
No
Note

In the only testcase of the first sample, selecting $$$i = 2$$$ for first operation, $$$i = 4$$$ for second, and $$$i = 2$$$ for third operation makes arrangement $$$a$$$ equal to arrangement $$$b$$$, thus the answer is "YES".

G. Moushi Is In Trouble
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Moushi is a very serious competitive programmer. As ICPC is approaching, her coach assigns her a strict training rule: she must solve an even number of problems every day.

To stay on track, she writes down her target solve count for the next $$$T$$$ days $$$X_1, X_2, \dots, X_T$$$ and goes to sleep.

However, she wakes up to find that the digit 9 has completely vanished from the world, making the number system consisting only of digits $$$0$$$ to $$$8$$$. Because of this change, she can no longer decide whether a number is even or odd by simply checking its last digit.

To ensure that her target of the day complies with the coach's requirement, Moushi needs to re-evaluate all the numbers under this new base-$$$9$$$ numeral system.

Input

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 10^3$$$) — the number of days.

The $$$i$$$-th of the next $$$T$$$ lines contains two space-separated integers $$$n_i$$$ and $$$X_i$$$ ($$$1 \le n_i \le 10^5$$$), where $$$n_i$$$ is the number of digits in $$$X_i$$$, and $$$X_i$$$ is the number of problems (in base-$$$9$$$) Moushi needs to solve on day $$$i$$$.

It is guaranteed that $$$X_i$$$ does not contain leading zeros.

It is also guaranteed that the sum of $$$n_i$$$ over all days does not exceed $$$10^5$$$.

Output

For each day, output "YES" if the goal for that day is valid, "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Example
Input
5
1 8
4 1234
5 12345
32 12345678123456781234567812345678
20 12345671234567123456
Output
YES
YES
NO
YES
NO

H. Unf-AI-r Task
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Tariq needs to solve the following math problem for his homework:

"I have 178632754 apples currently. I ate 76987266 apples yesterday. How many apples do I have currently? Provide only the numerical answer."

He decided to consult with ChatGPT for help.

Figure: Conversation with ChatGPT. May 20, 2026, 10:07 AM.

However, Tariq does not fully trust ChatGPT's answer, so he came to you. Can you provide the correct answer?

Input

This problem has no input.

Output

Output one single integer — the number of apples.

I. Iris Out
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Denji and Reze went to explore a school building at night. The building has $$$4$$$ rooms arranged in a $$$2 \times 2$$$ grid. Each room contains a light bulb, but the electrical system is malfunctioning.

Each room has a switch, but the switches are broken. Pressing the switch in a room does not affect the light in that room. Instead, it toggles the lights in the two adjacent rooms, namely the rooms directly above, below, to the left, or to the right. Toggling a light means changing its state from ON to OFF, or OFF to ON.

Reze asked Denji to turn all the lights OFF. Denji can press any switch any number of times and in any order. Given the initial state of the lights, determine whether it is possible for him to turn all the lights OFF at the same time.

Input

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

Each test case consists of two lines, each containing exactly two characters. These two lines represent the two rows of the $$$2 \times 2$$$ grid of rooms. For each character, a value of 0 means that the light in the corresponding room is initially OFF, and a value of 1 means that the light in the corresponding room is initially ON.

Output

For each test case, output "YES" if it is possible to turn all the lights OFF at the same time, "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Example
Input
4
00
00
11
11
01
00
10
01
Output
YES
YES
NO
YES
Note

In the first test case, all the lights are already OFF.

The following is the illustration of the second test case. The blue highlight indicates the next switch to be pressed.

It can be proven that it is not possible to turn all the lights OFF at the same time in the third test case.

J. The Grand Fleet's Logbook
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The New World is a chaotic sea, but even the most notorious pirate crews have a rhythm to their madness. "Big News" Morgans, president of the World Economy News Paper, has discovered that every pirate crew follows a bizarre, endlessly repeating cycle of daily activities. He is utilizing this predictability to track their movements, anticipate clashes, and write his next front-page headline.

There are $$$K$$$ pirate crews currently being tracked. Each crew $$$i$$$ enters the New World on a specific starting date and follows an infinitely repeating activity cycle represented by a string $$$P_i$$$. The string consists of the characters S (Sailing), F (Fighting), P (Partying), and D (Docked).

For example, if a crew's pattern is SFFD, they will spend their first active day sailing, the next two days fighting, the fourth day docked, and on the fifth day, the cycle restarts with sailing. A crew is considered strictly inactive on any date prior to their starting date.

Morgans has a series of $$$Q$$$ queries to track the fleets. You must process three types of queries:

  • Type 1 (1 DD/MM/YYYY C): Find all active crews engaged in a specific activity on a given date. Here, DD/MM/YYYY is the date to check, and C is a single character (S, F, P, or D) representing the target activity.
  • Type 2 (2 $$$N_i$$$ MM YYYY): Calculate the total number of days a specific crew spent Sailing (S), Fighting (F), and Partying (P) during a given calendar month. Here, $$$N_i$$$ is the name of the crew, MM is the two-digit month (e.g., 01 to 12), and YYYY is the four-digit year.
  • Type 3 (3 $$$N_1$$$ $$$N_2$$$ DD/MM/YYYY): Morgans anticipates a clash. Here, $$$N_1$$$ and $$$N_2$$$ are the names of two distinct crews, and DD/MM/YYYY is the starting date. Starting from this date, check a window of exactly $$$69$$$ days (the given date and the $$$68$$$ days following it). Find the first date within this window where both specified crews are active and Fighting (F) on the exact same day.
Input

The first line contains a single integer $$$K$$$ ($$$1 \le K \le 50$$$) — the number of pirate crews.

The following $$$K$$$ lines describe the crews. The $$$i$$$-th line contains three space-separated strings:

  • $$$N_i$$$ ($$$1 \le |N_i| \le 20$$$) — the name of the crew, consisting only of uppercase English letters. All crew names are distinct.
  • $$$D_i$$$ — the starting date of the crew's cycle, given in the strict format DD/MM/YYYY (with leading zeros for single-digit days and months).
  • $$$P_i$$$ ($$$1 \le |P_i| \le 100$$$) — the activity cycle of the crew, consisting only of characters from the set {S, F, P, D}.

The next line contains a single integer $$$Q$$$ ($$$1 \le Q \le 5000$$$) — the number of queries.

The following $$$Q$$$ lines each contain a space-separated query in one of the following formats:

  • 1 DD/MM/YYYY C: Where $$$C$$$ is a single character from the set {S, F, P, D}.
  • 2 $$$N_i$$$ MM YYYY: Where $$$N_i$$$ is a valid crew name from the input, MM is a $$$2$$$-digit month (01 to 12), and YYYY is a $$$4$$$-digit year.
  • 3 $$$N_1$$$ $$$N_2$$$ DD/MM/YYYY: Where $$$N_1$$$ and $$$N_2$$$ are valid, distinct crew names, and the date is given in standard format.

All dates in the input are guaranteed to be valid and fall within the range 01/01/2000 to 31/12/2050 inclusive. Additionally, for Type 3 queries, it is guaranteed that the entire $$$69$$$-day window (the given date and the $$$68$$$ days following it) will strictly fall on or before 31/12/2050.

Output

For each query, output the answer on a new line:

  • Type 1: Output the names of all active crews performing the queried activity on that date. The names must be space-separated and printed in lexicographical (alphabetical) order. If no active crew is performing the activity, output NONE.
  • Type 2: Output three space-separated integers representing the total number of S days, F days, and P days the crew had in that month, respectively. If the month occurs entirely before the crew's start date, output 0 0 0.
  • Type 3: Output the first date of the clash in the exact format DD/MM/YYYY. If the two crews never fight on the same day within the $$$69$$$-day window, output PEACE.
Example
Input
4
STRAWHAT 28/02/2024 SFF
HEART 01/03/2024 FDD
KID 01/03/2024 SFP
BUGGY 01/01/2024 P
6
1 01/03/2024 F
1 29/02/2024 D
2 STRAWHAT 02 2024
2 HEART 02 2024
3 STRAWHAT HEART 28/02/2024
3 BUGGY KID 01/01/2024
Output
HEART STRAWHAT
NONE
1 1 0
0 0 0
01/03/2024
PEACE
Note
  • Leap Year Rules: A year is a leap year if it is exactly divisible by $$$4$$$. However, if the year is divisible by $$$100$$$, it is not a leap year, unless it is also exactly divisible by $$$400$$$. For example, the years $$$2000$$$ (divisible by $$$400$$$), $$$2004$$$, and $$$2024$$$ are leap years, whereas $$$2100$$$ (divisible by $$$100$$$ but not $$$400$$$) and $$$2001$$$ are not.
  • Month Lengths: $$$31$$$ days (January, March, May, July, August, October, December), $$$30$$$ days (April, June, September, November), and February has $$$28$$$ days ($$$29$$$ in a leap year).

Explanation of the test case

The year 2024 is a leap year, meaning February has 29 days.

  • Query 1 (1 01/03/2024 F): We are looking for crews Fighting (F) on March 1st.
    • STRAWHAT started on Feb 28th. March 1st is Day $$$3$$$ of their journey (index $$$2$$$). Their pattern is SFF, so on index $$$2$$$ they are Fighting (F).
    • HEART started on March 1st. This is Day $$$1$$$ (index $$$0$$$). Their pattern is FDD, so they are Fighting (F).
    • KID started on March 1st. On Day $$$1$$$ (index $$$0$$$) of their SFP pattern, they are Sailing (S).
    • BUGGY only Parties (P).
    Both HEART and STRAWHAT are Fighting, so they are printed in alphabetical order.

  • Query 2 (1 29/02/2024 D): We are looking for Docked (D) crews on Leap Day. HEART and KID have not started their journeys yet. STRAWHAT is on Day $$$2$$$ (index $$$1$$$ of SFF $$$\rightarrow$$$ F). BUGGY is Partying. No active crew is Docked, so the output is NONE.

  • Query 3 (2 STRAWHAT 02 2024): We must count the activities for STRAWHAT during February 2024. Since they started on Feb 28th, they were only active for two days in this month: Feb 28th (S) and Feb 29th (F). The count is $$$1$$$ S, $$$1$$$ F, $$$0$$$ P.

  • Query 4 (2 HEART 02 2024): HEART does not begin their journey until March 1st. They were entirely inactive during February, resulting in 0 0 0.

  • Query 5 (3 STRAWHAT HEART 28/02/2024): We scan forward from Feb 28th to find the first day both crews Fight. HEART is inactive on the 28th and 29th. On March 1st, as calculated in Query 1, both crews are active and Fighting (F) simultaneously.

  • Query 6 (3 BUGGY KID 01/01/2024): We check the $$$69$$$-day window starting Jan 1st for a clash. However, BUGGY's pattern is entirely P (Partying). Because they never Fight (F), a clash is impossible. The output is PEACE.

K. Power of Friendship
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In an advanced material science lab, researchers are studying the crystal structure of alkali metals, such as sodium and potassium. These metals form a body-centered cubic (BCC) lattice, which is a repeating three-dimensional arrangement of atoms.

In a BCC lattice, each unit cell consists of one atom at the center of the cube and eight atoms at the corners of the cube. Each corner atom is shared by eight adjacent unit cells.

The domain of an atom is the region where its force strength is stronger than that of any other atom. In other words, the domain of an atom is the set of points that are closer to that atom than any other atom.

Your task is to calculate the volume of the domain of a center atom of a BCC lattice given its lattice spacing (side length of the unit cells) as a fraction $$$\dfrac{p}{q}$$$.

Input

The first line of the input contains an integer $$$t \: (1 \leq t \leq 100)$$$ — the number of test cases.

Each test case consists of a single line containing two space-separated integers $$$p$$$ and $$$q \:(1 \leq p, q \leq 100)$$$ — the numerator and the denominator of the fraction representing the lattice spacing.

Output

For each test case, output a single number in a line — the volume of the domain of a center atom.

The answer will be considered correct if the absolute error does not exceed $$$10^{-6}$$$.

Example
Input
2
7 3
15 4
Output
6.351852
26.367188
Note

The domain of the center atom in a unit cell is illustrated in the following figure: