Clique
Time limit25sMemory limit512 MB
Given n arcs on a circle of 10^6 arcs, find the largest number of arcs where every pair shares at least one arc.
Problem
A circle is divided into arcs numbered clockwise from 1 to . There are segments on the circle, each spanning a connected interval of arcs.
Find the size of the largest set of segments such that every two of them share at least one common arc.
Input
The first line contains the number of test cases . Each test case begins with a line containing the number of segments (). The following lines each contain two integers and (), the first and last arc of the -th segment when traversed clockwise. No segment covers the entire circle, and no two segments are the same.
The sum of over all test cases does not exceed 24000.
Output
For each test case, output a single line containing one integer: the size of the largest set of segments such that every two of them intersect.