PROGRAMMING:Nine serial problems
Jiulianhuan is a kind of traditional folk intellectual toy which is popular in Shanxi Province. It is composed of nine rings connected in a string, and it is better to untie them.
![ Photo 1. JPG] (~ / 34dc398b-7154-4a18-9afd-4a06a6598ac8. JPG)
The nine rings of the nine links are put on the hairpin one by one. In addition to the ring No. $$1 $, which can be installed or removed at any time, the condition for other rings to be installed or removed is that only the ring close to it is on the hairpin in front of it. That is, when the ring No. $$1 ~ $$I - 2 is not on the hairpin and the ring No. $$I - 1 is on the hairpin, the ring No. $$I can be installed or removed.
####Input format
>Loop number operation (U means to install, D means to remove)
####Output format
>The operation steps of mounting or dismounting jiulianhuan
>Each line displays one step of operation. The specific format is as follows:
>Ring number: u or D (u for installation, D for removal)
####Input sample 1
```in
3 U
```
####Output sample 1
```out
1: U
2: U
1: D
3: U
1: U
```
####Input sample 2
```in
4 D
```
####Output sample 2
```out
2: D
1: D
4: D
1: U
2: U
1: D
3: D
1: U
2: D
1: D
```
answer:If there is no answer, please comment
![ Photo 1. JPG] (~ / 34dc398b-7154-4a18-9afd-4a06a6598ac8. JPG)
The nine rings of the nine links are put on the hairpin one by one. In addition to the ring No. $$1 $, which can be installed or removed at any time, the condition for other rings to be installed or removed is that only the ring close to it is on the hairpin in front of it. That is, when the ring No. $$1 ~ $$I - 2 is not on the hairpin and the ring No. $$I - 1 is on the hairpin, the ring No. $$I can be installed or removed.
####Input format
>Loop number operation (U means to install, D means to remove)
####Output format
>The operation steps of mounting or dismounting jiulianhuan
>Each line displays one step of operation. The specific format is as follows:
>Ring number: u or D (u for installation, D for removal)
####Input sample 1
```in
3 U
```
####Output sample 1
```out
1: U
2: U
1: D
3: U
1: U
```
####Input sample 2
```in
4 D
```
####Output sample 2
```out
2: D
1: D
4: D
1: U
2: U
1: D
3: D
1: U
2: D
1: D
```
answer:If there is no answer, please comment