eolymp
bolt
Try our new interface for solving problems
Problems

Explosion

Explosion

You are the designer of a conveyor belt for uranium fuel rods. Several L-shaped rods will be attached to the belt. Every rod consists of a horizontal and a vertical arm, of not necessarily equal lengths. \includegraphics{https://static.e-olymp.com/content/a2/a22d56c6123e8a9a3aff0daabb9b894ef396d5d5.jpg} The coordinates of the point where a rod is attached to the belt are (\textbf{k}; \textbf{k}), where \textbf{k} denotes the rod's number. This point is the left end of the horizontal arm and the upper end of the vertical arm. You don't have to be reminded that if you put too much uranium in the same place, bad things happen (and remember who is to blame). This brings up the question of the maximum set of rods such that every two rods share a point. \InputFile The first line contains the numer \textbf{t} of test cases. The test cases follow. Each test case begins with a single integer \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{100 000}) in a separate line. The next \textbf{n} lines contain descriptions of rods. The \textbf{i}-th line of the description contains two nonnegative integers \textbf{v_i}, \textbf{h_i} ≤ \textbf{100 000} which denote the lengths of the vertical and the horizontal arm of the rod number \textbf{i}, respectively. \OutputFile For each test case, output one integer on a separate line: the number of elements in the maximum set of rods such that every two elements of this set have a common point. An end of a rod is also considered a part of the rod.
Time limit 2 seconds
Memory limit 128 MiB
Input example #1
1
8
1 2
2 6
1 5
4 0
3 3
2 2
5 2
2 1
Output example #1
4
Source 2013 Petrozavodsk Winter Training Camp, Jagiellonian University Contest, January 25, Problem E