Negative People in Da House

No attempts yetTime limit1sMemory limit256 MB

Problem

A math joke, for your amusement. Two mathematicians sit in a car parked outside a house. Two people walk into the house. A little later, three people walk out of it. One of the mathematicians says: "If one more person goes in now, the house will be empty!"

You have very little sense of humor, so you write a program instead. Given the record of people entering and leaving the house, find the smallest number of people that must have been inside before the observation started. The number of people inside the house is never negative at any moment.

Input

The first line contains a single integer TT, the number of test cases. Each test case starts with a line containing a single integer MM. The next MM lines each contain two integers P1P_1 and P2P_2 separated by a space. Each of those lines describes two events in order: first P1P_1 people enter the house, then P2P_2 people leave it.

  • 0<T500 < T \le 50
  • 0<M1000 < M \le 100
  • 0P1,P210000 \le P_1, P_2 \le 1000

Output

For each test case, print on its own line the smallest number of people that must have been inside the house at the beginning.