Tyler is a competitive rocket racer. Unlike in normal foot racing, rocket racers use their own collection of rockets to move instead of their feet. Tyler's collection consists of
- If
then an integer follows, and you must tell Tyler the minimum number of rockets he needs to complete an meter race. Note that the race is completed if Tyler reaches or passes the finish line at the meter mark at any point. Also, all rockets may only be used in the forward direction (i.e. initially towards the finish line). - If
then two integers and follow, indicating that Tyler replaces the -th rocket with one that propels him meters forwards but sends him meters backwards immediately after.
Constraints
Subtask 1 [25%]
Subtask 2 [25%]
Subtask 3 [50%]
No additional constraints.
Input Specification
The first line contains an integer
The next
The next line contains an integer
The next
Output Specification
For each event with
Sample Input
10
2 1
5 7
4 1
5 4
7 3
9 4
1 6
6 4
5 2
4 5
6
0 15
0 8
6 7 5
0 11
0 8
0 100
Sample Output
3
1
2
2
-1
Explanation
For the first event, Tyler should use his
For the fifth event, Tyler should use his
For the sixth event, it is impossible for Tyler to complete the race regardless of which rockets he chooses to use.
Comments