Every weekend a plane flies from Bitland to Vilnius. The passengers on this plane are very demanding and constantly trouble the crew: they keep asking for tea, a pillow, and so on.
While the crew tries to satisfy every request, the plane sometimes has to be kept circling above Vilnius before it can land! Naturally, the Bitland airline dislikes this, so from now on it asks its passengers to submit in advance a list of what they will request and when.
Given this list, find the minimum amount of time the flight attendant needs to fulfill all requests, assuming she plans her time optimally.
You also know that:
The first line contains the number of requests N.
Each of the next N lines contains two integers ai and bi describing one passenger request. Here ai is the number of the row where the passenger sits, and bi is the earliest time at which the i-th request is submitted (it may be fulfilled at that time or at any later time).
Print a single integer — the minimum number of minutes needed for the flight attendant to fulfill all requests and return to the first row.