Postman Joe is a fitness fanatic. He has a single row of 20 houses on his delivery route, and every day he sets himself a task that requires him to walk up and down the row several times. A typical task looks like this:
3 U3 D2 U1 U6 D4 D5 U7 U9 D5 D3 U5 U4 D2 D5 U8
This means that Joe delivers first to house 3, then moves 3 houses up the street and delivers to house 6, then moves 2 houses down the street and delivers to house 4, and so on. The houses are numbered sequentially from 1 to 20, with house 1 at the bottom of the street.
Not every house necessarily receives a delivery each day, but Joe's instructions must never take him to the same house twice, nor take him beyond either end of the row of houses.
Write a program to help Joe. It must check that Joe has set himself a legal task and, if so, report the houses that do not receive a delivery.
The input consists of several tasks that Joe has set, one per line. The final line contains a single # character and must not be processed.
Each task represents the deliveries for a single day. Each line begins with an integer $S$ ($1 \le S \le 20$), the first house to which Joe makes a delivery. This is followed by a sequence of letter-number pairs, each separated by a single space. The letter is U or D: U means go up the street (increasing house number) and D means go down the street (decreasing house number). The number is a single-digit integer giving how many houses to move.
Output one line for each task in the input.
If a task is legal (no house is visited twice, and Joe never moves beyond either end of the street), output the houses that do not receive a delivery that day, in increasing numerical order, separated by a single space. If every house receives a delivery, output the word none.
If a task is not legal, output the word illegal.
A task is illegal if any move lands Joe on a house he has already delivered to, or moves him beyond house 1 or house 20.
In the first example, Joe makes 16 deliveries, so 4 houses are left without one. In the second example the 7th delivery (D4) would send Joe back to house 1, which already received the 2nd delivery, so that task is illegal.