P7336 [JRKSJ R1] 1+1

Description

### Gameplay Overview "1+1" is a two-player competitive game. Each player has two numbers. On each turn, a player may add one of their own numbers to one of the opponent’s numbers; if the result is greater than $9$, then only the ones digit is kept. The two players take turns doing this. For example, the following records several rounds of the game, where the two players are `a` and `b`: In the explanations below, the first position marked with `*` is the first player. ``` a:1 1*(initial position) b:1 2 a:1 3(1+2) b:1 2 a:1 3 b:1 5(2+3) a:6 3(1+5) b:1 5 ``` --- ### Special Positions We call the following cases "attack": ``` 3 3 5 3 6 1 9 1 ``` The "attack level" of these attacks is $1$, except for `9 1`. The attack level of `9 1` is $2$. We call the following cases "defense": ``` 5 1 5 5 ``` The "defense level" of these defenses is $1$, except for `5 5`. The defense level of `5 5` is $2$. Of course, for all attacks or defenses, the order of the two numbers does not matter. For example, `5 1` and `1 5` are both considered defenses, and `9 1` and `1 9` are both considered attacks, with the same attack/defense levels. If player `a` has a defense, and player `b` makes an attack on the next move, as in the following: ``` a:1 5 b:1 1* a:1 5 b:6 1 ``` Then at this moment, `a` holds `1 5` with defense level $1$, and `b` holds `6 1` with attack level $1$. In this case, `a`’s numbers should be changed to `1 1`, and `b`’s attack this turn is invalid. That is, if `a`’s attack level is equal to `b`’s defense level, then change `b`’s two numbers to `1 1`, and treat `a`’s attack this turn as invalid. We consider the attack/defense level of any position not belonging to the above attacks/defenses to be $0$ (such as `3 4`, etc.). In particular, if the following situation occurs: ``` a:5 5 b:1 1* a:5 5 b:1 6 ``` `a`’s defense level is $2$ while `b`’s attack level is $1$. In this case, `a` should be changed to `5 1`, and `b`’s attack this turn is invalid. ------------ ### Winning Condition If after one side finishes a move, their attack level is strictly greater than the other side’s defense level, then that side wins. In this case, no changes should be made, even if the rules would otherwise require changing the other side to `1 1` or `5 1`. An example is given below: ``` a:1 1 b:6 3* a:1 1 b:6 4 a:1 5 b:6 4 a:1 5 b:6 9 a:1 1 b:6 9 a:1 1 b:6 0 a:1 7 b:6 0 a:1 7 b:6 1 ( b wins) ``` To remove ambiguity, here are some more examples: ``` a:5 5 b:1 4* a:1 1 b:1 9 a:1 0( 1+9=10 ,the ones digit is 0 ) b:1 9 a:1 0 b:1 9(note here: b used 1 (or 9) plus a’s 0, which also counts as a new attack) ( b wins) ``` ``` a:1 1* b:1 4 a:1 5 b:1 4 a:1 5(because this is the last move, there is no need to change to “1 1”) b:1 9(here b’s “1 9” directly crushes a’s “1 5”) ( b wins) ``` Now, you are asked to write a program to play this game as the first player, via interaction, against mcyl35’s program.

Input Format

The first line contains five integers $p_0,p_1,c_0,c_1,P$, which represent your two numbers, mcyl35’s two numbers, and the test point ID. Each following line contains two integers $x,y$, indicating that mcyl35’s $x$-th number was added to your $y$-th number. This problem uses interactive IO. For details, see [P1733 Guess the Number (Interactive IO Version)](https://www.luogu.com.cn/problem/P1733).

Output Format

Each line outputs two integers $x,y$, indicating that your $x$-th number is added to mcyl35’s $y$-th number.

Explanation/Hint

#### Constraints and Conventions For test point $1$, it is guaranteed that the player can win in one move. For test point $2$, it is guaranteed that mcyl35’s program makes random moves. For other test points, there are no special guarantees. For $100\%$ of the data, $0\le p_0,p_1,c_0,c_1\le 9$. #### Scoring Rules * If there is illegal output (for example, the output contains numbers other than $0,1$), you get $0$ points. * If you win, or if mcyl35 makes $100$ moves or more in this test point, you get full score. * Otherwise, you get $\lfloor \dfrac {st} {20} \rfloor$ points, where $st$ is the number of moves taken, and one move means mcyl35 makes one move. #### Notes When the interactive library does not return a number, it means the result has already been judged. #### Sample Explanation ``` pl:1 1* cp:1 2 pl:2 1 cp:1 2 pl:2 1 cp:1 3 pl:5 1 cp:1 3 pl:5 1 cp:1 8 pl:6 1(Win) cp:1 8 ``` Translated by ChatGPT 5