Not a long time ago Y wasn't a prisoner and he had a lot of friends (n friends). His friends are going to plan a date in upcoming 106 days as soon as possible in a day that none of them are busy in that day.
His ith friend is busy in mi intervals of days:
What is the earliest day that none of his friends are busy?
Input
First line contains only an integer n, number of his friends.
Then follwing n pairs for lines contain:
1≤n≤2×105
0≤∑mi≤2×105
Output
The only line of output contains an integer, the earliest day that none of his friends are busy. if there isn't any day that none of them are busy print −1.
All Y's firends has two busy intervalse that they cover all days from 1 to 7. all of them are not busy in 8th day, so the answer is 8.