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 0 to time 10. 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.
The first line has a positive integer n, the number of days, that is, the number of test cases. (1≤n≤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 s and the finish time f. (0≤s≤9, 1≤f≤10, s<f) An event uses at least 1 hour.
The line 0 0 marks the end of a test case.
For each test case, print on its own line the maximum number of events that can be arranged in the meeting room.