P10460 Defense Line
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 $N$ 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 $S$, $E$, and $D$ to describe a group: this group is placed at positions $S, S + D, S + 2D, \dots, S + KD$ ($K\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 $0$ 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 $T$, meaning there are $T$ independent test cases.
For each test case, the first line contains an integer $N$.
The next $N$ lines each contain three integers $S_i$, $E_i$, $D_i$, representing the three parameters of the $i$-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 $P$ and $C$ on one line, meaning there are $C$ armor pieces at position $P$. Of course, $C$ should be an odd number.
Explanation/Hint
For $30\%$ of the data, the total number of armor pieces is at most $10 ^ {7}$.
For $100\%$ of the data, the total number of armor pieces is at most $10 ^ {8}$, $S_{i}\le E_{i}$, $1\le T \le 5$, $N \le 2\times 10^5$, $0 \le S_{i}$, $E_{i}$, $D_{i} \le 2^{31} - 1$.
Constraints.
Translated by ChatGPT 5