A circular combination lock has a dial with the numbers $0$ through $n-1$ printed on it in clockwise order. Turning the dial brings one of the numbers to the top. If $0$ is at the top, turning the dial counterclockwise by $1$ brings $1$ to the top, and turning it clockwise by $1$ brings $n-1$ to the top.
Each lock has a three-number code $(x, y, z)$ and can be opened only by performing the following steps in order:
Any turn made after step 3 closes the lock again.
You are given a lock and a sequence of turns. Before the first turn the lock is closed and the dial has been set with $0$ at the top. Determine whether the lock is open after the last turn.
The input contains several test cases.
The first line of each test case has four integers $n$ $x$ $y$ $z$: the number of digits on the dial and the three-number code. The values $x$, $y$, and $z$ are all different, and $n \le 1000$.
The following line or lines list the turns, each written as d s, where d is C for clockwise or CC for counterclockwise, and $s > 0$ is how many numbers pass the top during that turn. For example, with $n = 50$ and $4$ currently at the top, CC 6 brings $10$ to the top while C 6 brings $48$ to the top. The list of turns may span several lines and ends with a ?.
A line containing a single 0 follows the last test case.
For each test case, print one line: Case k: Open if the lock is open after the last turn, or Case k: Closed otherwise, where $k$ is the test case number starting from $1$.