It's time for the members of The Team to do what they do best - coding!
Faster than you can say "Dijkstra", they've already produced an elegant
piece of work. The program has
c++;
— The value of is incremented by 1. Then, if , the program terminates - otherwise, the program moves to line .x:
— This line contains the label , where is an integer such that . No value of will appear as a label more than once in the program. If , the program terminates - otherwise, the program moves to line .goto x;
— The program jumps to the single line that contains the label , where is an integer such that . It is guaranteed that, for every such line, the corresponding label will exist in the program.
Now, even though this program is glorious, its creators are wondering if
it's quite correct. In particular, they know that
Input Specification
First line: 2 integers,
Next
Output Specification
Either 1 integer, the number of the line on which WA
if the program terminates with TLE
if the program runs forever with
Sample Input
12 4
c++;
goto 6;
18:
c++;
c++;
goto 2;
goto 6;
6:
goto 18;
2:
c++;
c++;
Sample Output
11
Explanation of Sample
The program will run through the following lines, and corresponding
values of
- Line 1 (
c++;
), - Line 2 (
goto 6;
), - Line 8 (
6:
), - Line 9 (
goto 18;
), - Line 3 (
18:
), - Line 4 (
c++;
), - Line 5 (
c++;
), - Line 6 (
goto 2;
), - Line 10 (
2:
), - Line 11 (
c++;
),
As can be seen,
Comments