


1. The time starts from zero.
2. Before completing one task another task can not be started.
3. The reward for doing a task can be negative.
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain a single integer ‘N’ which denotes the number of tasks.
The next ‘N’ lines contain the two space-separated integers “ARR[i][0]” and “ARR[i][1]”, where “ARR[i][0]” is the duration of the ‘i-th’ task and “ARR[i][1]” is the deadline of the ‘i-th’ task.
For each test case, print the maximum reward for doing all the tasks.
Output for every test case will be printed in a separate line.
You don’t need to print anything; It has already been taken care of.
1 <= T <= 10
1 <= N <= 100000
1 <= ARR[ i ][ 0 ] and ARR[ i ][ 1 ] <= 10^5
Where ‘T’ is the number of test cases, 'N' is the number of tasks, ‘ARR[ i ][ 0 ]’ is the duration and ‘ARR[ i ][ 1 ]’ deadline of the ‘i-th’ task.
Time limit: 1 sec
If there are two tasks ‘i-th’ and ‘i + 1-th’ and the duration of ‘i+1-th’ task is smaller than ‘i-th’ task then it is always optimal to swap two tasks.
So, tasks sorted by their duration will always be optimal.