Our department has a seminar room equipped with many conveniences, and several research groups want to use it. To build a weekly schedule for the room, each research group submits a candidate time interval for its own seminar.
Because some of the submitted candidate intervals overlapped, assigning the room fairly became hard. So every group is now asked to submit two candidate intervals. The two intervals a group submits may overlap each other, but one must not be fully contained in the other.
The task is to decide whether one of the two candidate intervals can be assigned to each group so that the assigned intervals do not overlap one another. If the finish time of one interval equals the start time of another, the two intervals are not considered to overlap.
Each candidate interval is given as a pair of a start time and a finish time. A time is written as ddd:hh:mm, where ddd is three capital letters for the day of the week, hh is the hour (00≤hh≤23), and mm is the minute (00≤mm≤59). No reservation is made on Sundays, so ddd is one of MON, TUE, WED, THU, FRI, SAT.
For example, suppose there are three research groups with the candidate intervals shown below.
| Research group | Candidate intervals |
|---|---|
| Group 1 | MON:09:00 MON:11:00 |
MON:10:00 MON:12:00 | |
| Group 2 | MON:09:00 MON:11:30 |
TUE:13:25 TUE:14:27 | |
| Group 3 | MON:09:30 MON:11:00 |
MON:23:00 TUE:01:00 |
If groups 1, 2, and 3 are assigned MON 09:00 - MON 11:00, TUE 13:25 - TUE 14:27, and MON 23:00 - TUE 01:00 respectively, the three intervals do not overlap, so every group can be satisfied.
Write a program that, given two candidate intervals per group, decides whether one interval can be assigned to each group so that no two assigned intervals overlap.
Your program reads from standard input. The input consists of T test cases. The first line contains the number of test cases T.
Each test case begins with a line containing a positive integer n (n≤1000), the number of research groups. Each of the next n lines gives one group's two candidate intervals as four times s1 f1 s2 f2, meaning the intervals [s1 - f1] and [s2 - f2]. The times are separated by single spaces.
Your program writes to standard output. Print exactly one line per test case. Print YES if one candidate interval can be assigned to each group so that all assigned intervals are pairwise non-overlapping; otherwise print NO.