It's time for Oliver to do his daily chores. There are
Input Specification
The first line will contain one integer
The next
Output Specification
Print one integer, the minimum efficiency score possible. Since this number may be very large, output it modulo
Sample Input 1
3
2 1
4 3
1 2
Sample Output 1
43
Sample Input 2
1
100 1000000000
Sample Output 2
2100
Sample Input 3
5
6 3
2 4
1 1
10 12
3 4
Sample Output 3
1438
Comments