#Lutece1045. Lovely princess

Lovely princess

Migrated from Lutece 1045 Lovely princess

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

There are nn jobs you need to complete. However, complete the ithi_{th} job you capability must be no less than viv_i. If you have completed the ithi_{th} job, your capability will increase aia_i.

Then the question is coming, what is the minimum initial capability value if you are required to complete all of the nn jobs.

Note that there is no restriction on the order you complete them. That is to say, you can decide the order by your own.

Input

The first line contains a single integer nn, which is the number of jobs you need to complete.

Then each of the following nn lines contains 22 integers viv_i and aia_i, which are described above.

$1 \leq n \leq 1000, 0 \leq v_i \leq 1000000, 0 \leq a_i \leq 1000$

Output

Print the answer in one line.

Samples

1
2 1
2

Resources

The 13th UESTC Programming Contest Preliminary