Input 1
3 8
3 30
4 50
5 60
Output 1
90
Input 2
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
Output 2
5000000000
Input 3
6 15
6 5
5 6
6 4
6 6
3 5
7 2
Output 3
17
3 8
3 30
4 50
5 60
90
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
5000000000
6 15
6 5
5 6
6 4
6 6
3 5
7 2
17
Nhận xét