Organizing SWERC

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

문제

Gianni, SWERC’s chief judge, received a huge amount of high quality problems from the judges and now he has to choose a problem set for SWERC.

He received nn problems and he assigned a beauty score and a difficulty to each of them. The ii-th problem has beauty score equal to b_ib\_i and difficulty equal to d_id\_i. The beauty and the difficulty are integers between 11 and 1010.

If there are no problems with a certain difficulty (the possible difficulties are 11, 22, \dots, 1010) then Gianni will ask for more problems to the judges.

Otherwise, for each difficulty between 11 and 1010, he will put in the problem set one of the most beautiful problems with such difficulty (so the problem set will contain exactly 1010 problems with distinct difficulties). You shall compute the total beauty of the problem set, that is the sum of the beauty scores of the problems chosen by Gianni.

입력

Each test contains multiple test cases. The first line contains an integer tt (1t1001 ≤ t ≤ 100) — the number of test cases. The descriptions of the tt test cases follow.

The first line of each test case contains the integer nn (1n1001 ≤ n ≤ 100) — how many problems Gianni received from the judges.

The next nn lines contain two integers each. The ii-th of such lines contains b_ib\_i and d_id\_i (1b_i,d_i101 ≤ b\_i , d\_i ≤ 10) — the beauty score and the difficulty of the ii-th problem.

출력

For each test case, print the total beauty of the problem set chosen by Gianni. If Gianni cannot create a problem set (because there are no problems with a certain difficulty) print the string MOREPROBLEMS (all letters are uppercase, there are no spaces).