favorite We need a little bit of your help to keep things running, click on this banner to learn more

Week 3: November 23 – 29. For Loop. Part 2


Student Valera is a classic example of the idler. In classes, he almost did not go, and only appears at the end of the semester at the university and deliver "tails". His dream: to find a day when it will be possible to pass at once all the debts. He has a schedule of work for teachers, of whom know exactly what to and what day of the month, each teacher will be available daily. Help Valera write a program that is scheduled to determine whether Valera pass all debts in one day or not.


The first line contains the number of test cases. Each test consists of a number n (1n100) of items that need to pass Valera. This is followed by n lines, each of which consists of two numbers a and b (1ab31), specify the interval of the regular teacher.


For each test print in a separate line "YES" if it is possible to meet all the teachers at one day, or "NO", if this is impossible.

Time limit 1 second
Memory limit 128 MiB
Input example #1
1 2
1 2
3 4
Output example #1