Schedule

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

There are NN tasks: the ii-th task has to start at moment s_is\_i and finish at moment e_ie\_i. There is also a potentially infinite supply of machines. We want to assign tasks to machines. Each task will be assigned to one machine. On the other hand, each machine may handle an arbitrary number of tasks as long as no two of them overlap. Tasks ii and jj are said to overlap if the intersection of the open intervals (s_i,e_i)(s\_i, e\_i) and (s_j,e_j)(s\_j, e\_j) is non-empty.

A machine is turned on at the moment when the earliest of its assigned tasks has to start, and turned off at the moment when the latest of them has to finish. The working time of a machine is the length of the time period between these two moments: we cannot turn a single machine on and off more than once.

Your task is to find the minimum possible number of machines KK such that we can use only KK machines to perform all tasks. Additionally, when using KK machines, find the minimum possible sum of all their working times.

입력

The first line of input contains an integer TT, the number of test cases (1T1001 \le T \le 100).

Each test case begins with a line containing one integer NN (0<N1050 < N \le 10^5). Each of the next NN lines contains two integers s_is\_i and e_ie\_i (0s_i<e_i1090 \le s\_i < e\_i \le 10^9).

It is guaranteed that N>50N > 50 for no more than 10 test cases.

출력

For each test case, print two integers in one line: the minimum possible number of machines KK to perform all tasks and the minimum sum of all working times when using KK machines.