|
Ako |
Testing, testing. Can you hear me? Field operatives on standby, please respond. |
|
Iori |
This is Codename S. I have arrived on site. |
|
Chinatsu |
This is Codename H. I have arrived as well. |
|
Ako |
Yes, communications are clear. Everyone is accounted for. Now, I will go over the outline of this operation once more. |
|
Ako |
The Prefect Team’s summer training camp ends today at 4 p.m., when we are scheduled to return. |
|
Ako |
The only item on today’s schedule that we told the Head Prefect about was the group shooting practice this afternoon. |
|
Ako |
However, before that practice, she wished to take some time to practice swimming at the beach. |
|
Ako |
Which means... this is proof that she, too, has begun to think of this time as a vacation! |
|
Ako |
Then our mission is simple. We must support her vacation with everything we have, right to the end! |
|
Ako |
Specifically, we will eliminate any potential dangers on the beach and secure the area, setting the stage for her to enjoy her vacation! |
|
Iori |
No matter how I look at it, isn’t this an abuse of power...? |
|
Chinatsu |
At least there are no visitors after the previous commotion... |
|
Ako |
Enough back talk! Please! There must be absolutely no mistakes! |
Hello. I am Ako, senior administrator of Gehenna Academy’s Prefect Team. Until 4 p.m. today, we will have complete control of the beach so that the Head Prefect can practice swimming safely. To that end, I will now prepare the deployment schedule for our operatives.
The operation is divided into deployment slots, numbered through . Exactly field operative is assigned to each slot. There are also operatives, numbered through , and each operative will be deployed exactly once today.
The first line contains the number of test cases .
For each test case, the first line contains . The next lines describe the allowed deployment intervals. The -th of these lines contains , , separated by a space. ;
For each test case, print the following three integers in order, separated by spaces on one line.
Thus, I will prepare a schedule of length containing each operative from to exactly once. However, I cannot assign them arbitrarily. Each operative must be assigned to a slot from through , inclusive.
The pairs for operatives through have already been determined. Only for operative remains undecided. We may choose any satisfying .
Here is the issue. For each choice of , we must determine whether
We must count the pairs that fall into each of these three cases.
The sum of over all test cases is at most .