Meeting Room Arrangement

No attempts yetTime limit1sMemory limit128 MB

Problem

A faculty of engineering has one large meeting room that its staff use for events and meetings. The room has to be reserved in advance. Only 10 hours of the room are available each day and more events want the room than fit into a day, so the best usage policy is to hold as many events as possible in one day.

The room is free from time 00 to time 1010. Given the start time and the finish time of every candidate event, select events whose times do not overlap and report the largest number of events that can be held in one day. An event may start at the exact time another event finishes.

Input

The first line has a positive integer nn, the number of days, that is, the number of test cases. (1n1001 \le n \le 100)

Each test case then lists the times of the candidate events, one event per line, with fewer than 20 events in a test case. A line has two integers separated by a space, the start time ss and the finish time ff. (0s90 \le s \le 9, 1f101 \le f \le 10, s<fs < f) An event uses at least 1 hour.

The line 0 0 marks the end of a test case.

Output

For each test case, print on its own line the maximum number of events that can be arranged in the meeting room.