#C3095. Running Intervals Overlap Check

    ID: 46484 Type: Default 1000ms 256MiB

Running Intervals Overlap Check

Running Intervals Overlap Check

In this problem, you are given T test cases. In each test case, there are n participants' running intervals, each defined by a start time and an end time. Your task is to determine whether there is any overlap among these intervals.

Two intervals, defined as \([a, b]\) and \([c, d]\), are considered to overlap if, after sorting by start times, the condition \[ a_{i+1} < b_i \] holds for any consecutive intervals \(i\) and \(i+1\). If such a pair exists in a test case, print YES; otherwise, print NO.

inputFormat

The input begins with an integer T denoting the number of test cases. Each test case starts with an integer n representing the number of intervals. This is followed by n lines, each containing two integers that denote the start and end times of an interval.

outputFormat

For each test case, output a single line with YES if there is at least one overlapping pair of intervals, or NO if there is no overlap.

## sample
2
3
1 5
2 6
8 10
4
1 3
4 6
7 9
10 12
YES

NO

</p>