Vaibhav has been really busy in planning and organising Amalthea (the Technical Summit of IIT Gandhinagar), and has constantly been postponing his assignments. As a result, he now has a huge number of assignments left to finish. Each assignment has to be submitted online on or before a specified deadline, and is worth a particular number of points. If an assignment is submitted after the deadline - no points will be awarded for doing that assignment.
Vaibhav knows that it it will take him at least one hour to finish each assignment. Due to the large number of assignments that he has to do, it may not be possible for him to finish each assignment before the deadline. Help Vaibhav select a subset of assignments that he can do in order to maximise the number of points he earns. Vaibhav starts doing his assignments at time t=0
. You are given the deadlines in terms of the number of hours left to submit the assignment from time t=0
.
Input Format
The first line contains a single integer T
representing the number of sub-tests . T
sub-tests follow.
The first line of each sub-test contains a single integer N
representing the number of assignments. N
lines follow.
Each line contains two space separated integers - D
and P
- representing the number of hours left from time t=0
to submit the assignment, and the number of points that the assignment is worth.
Output Format
For each sub-test, print a single integer representing the maximum number of points that Vaibhav can obtain
Constraints
1 <= T <= 10
1 <= N <= 100
1 <= D <= 100
1 <= P <= 10^3
Note
There is no partial scoring for this problem.