J. Just a Simple Postman Problem
time limit per test
8 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

You are responsible for delivering $$$n$$$ packages to the houses of a long street. Initially, you are located at position $$$0$$$, and the initial time is $$$0$$$. Moving one position unit takes you one time unit. Note that you can also wait at your current position.

For every package $$$i$$$, you are given a time $$$t_i$$$ and location $$$a_i$$$ meaning that you have to deliver the package to position $$$a_i$$$, and the person who ordered the package wants it to arrive at time $$$t_i$$$.

It is not possible to deliver the package at an earlier time since there might be nobody available.

Also, nowadays people tend to complain a lot. If they want their package to be delivered at time $$$t_i$$$ and it is delivered $$$x$$$ time units later, their angriness level is $$$x$$$. Since you don't want to lose your job because of bad reviews by angry customers, you want to find a way to minimize the maximum angriness level of a customer.

Input

The first line contains an integer $$$T$$$ ($$$1 \leq T \leq 10^5$$$), the number of testcases.

Each testcase consists of:

  • One line with one integer $$$n$$$ ($$$ 1 \leq n \leq 700$$$), the number of packages.
  • n lines, each with two integers $$$a_i$$$ and $$$t_i$$$ ($$$|a_i| \leq 10^8$$$, $$$1 \leq t_i \leq 10^8$$$), describing a package that should arrive at position $$$a_i$$$ not before time $$$t_i$$$.

Over all testcases, the sum of $$$n^2$$$ is at most $$$5 \cdot 10^5$$$.

Output

For each testcase, output one integer – the minimum maximum angriness level which can be achieved.

Example
Input
2
3
-5 4
-4 2
5 3
3
0 1
-4 1
0 2
Output
12
5