#P10460. 防线

防线

Problem Description

When lsp was studying math competitions, they suffered a lot of contempt from others. One day, after enduring endless humiliation, lsp turned to the dark side and became the dark hero Lord lsp. Just like in a chuunibyou manga plot, Lord lsp plans to destroy the world. The math competition elite lqr decides to stop Lord lsp's conspiracy, so she gathers a super task force made up of math competition contestants. Since every member is very smart, the team soon arrives beneath Lord lsp's dark castle.

However, the equally powerful Lord lsp has set up a solid “impassable” defense line around the castle. The defense line consists of many pieces of armor, divided into NN groups. We can treat the defense line as one-dimensional: each group of armor is placed along some segment of the line, and within the same group the armor is equally spaced. That is, we can use three integers SS, EE, and DD to describe a group: this group is placed at positions S,S+D,S+2D,,S+KDS, S + D, S + 2D, \dots, S + KD (KZ,S+KDE,S+(K+1)D>EK\in \Z, S + KD\leq E, S + (K + 1)D>E).

Lord lsp's defense line is extremely well designed. If a position on the defense line has an even number of armor pieces, then that position has no weakness (this also includes the case where there is no armor at that position, because 00 is also even). Only positions with an odd number of armor pieces have a weakness, and across the entire defense line there is at most one position with an odd number of armor pieces. As the captain of the task force, lqr needs to find the weakness to plan the next step. But since there are too many armor pieces, she cannot figure out where the weakness is. As juniors lqr can trust, you need to help her solve this problem.

Input Format

The first line of the input file contains an integer TT, meaning there are TT independent test cases.

For each test case, the first line contains an integer NN.

The next NN lines each contain three integers SiS_i, EiE_i, DiD_i, representing the three parameters of the ii-th group of armor.

Output Format

For each test case, if the defense line has no weakness, i.e., every position has an even number of armor pieces, output one line There's no weakness..

Otherwise, output two space-separated integers PP and CC on one line, meaning there are CC armor pieces at position PP. Of course, CC should be an odd number.

3
2
1 10 1 
2 10 1 
2
1 10 1 
1 10 1 
4
1 10 1 
4 4 1 
1 5 1 
6 10 1

1 1
There's no weakness. 
4 3

Hint

For 30%30\% of the data, the total number of armor pieces is at most 10710 ^ {7}.

For 100%100\% of the data, the total number of armor pieces is at most 10810 ^ {8}, SiEiS_{i}\le E_{i}, 1T51\le T \le 5, N2×105N \le 2\times 10^5, 0Si0 \le S_{i}, EiE_{i}, Di2311D_{i} \le 2^{31} - 1.

Constraints.

Translated by ChatGPT 5