#P4403. [BJWC2008] 秦腾与教学评估

[BJWC2008] 秦腾与教学评估

Description

In his first semester at Peking University, Qin Teng unfortunately encountered an unprecedented teaching evaluation.

During the evaluation, students were required to get up at 8 a.m., return to the dormitory at 11 p.m., were not allowed to skip classes, not allowed to be late, not allowed to sleep in class... Even the famous Triangle Area of PKU was demolished during the evaluation on the grounds that it affected the campus appearance. These "absurd" rules made students who were used to a free and easy life miserable.

It was Friday again, and early in the morning was Qin Teng’s least favorite Advanced Algebra class. But since it was the evaluation period, he could not be late, so at 8:05 he struggled out of the dorm, hoping to slip into the classroom that had already started at 8:00.

However, as soon as he left the dormitory building, he was stunned: the road from the dormitory to the teaching building was already lined with members of the evaluation team. Their goal was to catch late students like him and deduct points from the university.

Of course, Qin Teng could not let them succeed. He observed that the entire evaluation team was divided into NN groups. The members of each group were distributed on some segment of the road from the dormitory to the teaching building, and the distances between members of the same group were equal. Thus, we can describe a group with three integers S,E,DS,E,D: the members of this group are located at $:S,S+D,S+2D,\ldots,S+KD(K \in \mathbb Z,S+KD\le E,S+(K+1)D>E)$ along the road.

Seeing this pattern and thinking carefully, Qin Teng came up with a countermeasure: if there is a position on the road with an odd number of evaluation team members, he can use tricks such as "diaohu lishan", "shengdong xixi", "geshan daniu", and "andu chencang" to break through at that spot and reach the teaching building.

But the members were very cunning, and their arrangement was extremely clever, so that such a position hardly appeared on the whole road. Even if, by accident, such a position did appear, there would be at most one.

Now that Qin Teng has observed all the groups’ arrangements, he still cannot tell whether such a position exists because there are too many people.

Your task is to write a program to help him decide.

Input Format

The first line contains an integer TT.

Then TT independent testdata follow.

For each piece of testdata, the first line contains an integer NN.

Each of the next NN lines contains three integers Si,Ei,DiS_i,E_i,D_i, representing the three parameters of the ii-th group.

Output Format

For each testdata, if the required position does not exist, i.e., every position has an even number of evaluation team members, print one line: Poor QIN Teng:(.

Otherwise, print two integers Posi,Count\text{Posi},\text{Count}, meaning that at the unique position Posi\text{Posi} there are Count\text{Count} evaluation team members.

According to the statement, Count\text{Count} should be odd.

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 
Poor QIN Teng:( 
4 3 

Hint

Constraints:

  • The total number of evaluation team members is not greater than 10810^8.
  • SiEiS_i \le E_i.
  • 1T51 \le T \le 5.
  • N2×105N \le 2 \times 10^5.
  • 0Si,Ei,Di23110 \le S_i,E_i,D_i \le 2^{31}-1.
  • The size of the input file is not greater than 2048 KB.

Translated by ChatGPT 5