| Author: | Pavel Mesenev | Time limit: | 2 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
You are simulating a browser's history. The browser starts on the homepage, page 0. You are given n operations, each one of:
After every BACK and FORWARD operation, output the page you land on. VISIT produces no output.
The first line contains one integer n — the number of operations. Each of the next n lines is one operation in the format above.
For every BACK or FORWARD operation, print the resulting current page on its own line, in order.
1 ≤ n ≤ 2 ⋅ 105
1 ≤ x ≤ 109 for VISIT x
1 ≤ k ≤ 109 for BACK k / FORWARD k
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|