Problem Description

Commands: PUSH x, POP, ROTATE k (move first to end k times). Print final queue (space-separated).

Input Format

First line q. Next q lines.

Output Format

Final queue line.

Sample Test Case

Input:
6 PUSH 1 PUSH 2 PUSH 3 ROTATE 2 POP PUSH 4
Output:
2 3 4

Constraints

q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next