CF1455C.Ping-pong

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Ping-pong

Alice and Bob play ping-pong with simplified rules.

During the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must alternately make a return until one of them doesn't make a return.

The one who doesn't make a return loses this play. The winner of the play commences the next play. Alice starts the first play.

Alice has xx stamina and Bob has yy. To hit the ball (while serving or returning) each player spends 11 stamina, so if they don't have any stamina, they can't return the ball (and lose the play) or can't serve the ball (in this case, the other player serves the ball instead). If both players run out of stamina, the game is over.

Sometimes, it's strategically optimal not to return the ball, lose the current play, but save the stamina. On the contrary, when the server commences a play, they have to hit the ball, if they have some stamina left.

Both Alice and Bob play optimally and want to, firstly, maximize their number of wins and, secondly, minimize the number of wins of their opponent.

Calculate the resulting number of Alice's and Bob's wins.

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The first and only line of each test case contains two integers xx and yy (1x,y1061 \le x, y \le 10^6) — Alice's and Bob's initial stamina.

Output

For each test case, print two integers — the resulting number of Alice's and Bob's wins, if both of them play optimally.

Note

In the first test case, Alice serves the ball and spends 11 stamina. Then Bob returns the ball and also spends 11 stamina. Alice can't return the ball since she has no stamina left and loses the play. Both of them ran out of stamina, so the game is over with 00 Alice's wins and 11 Bob's wins.

In the second test case, Alice serves the ball and spends 11 stamina. Bob decides not to return the ball — he loses the play but saves stamina. Alice, as the winner of the last play, serves the ball in the next play and spends 11 more stamina. This time, Bob returns the ball and spends 11 stamina. Alice doesn't have any stamina left, so she can't return the ball and loses the play. Both of them ran out of stamina, so the game is over with 11 Alice's and 11 Bob's win.

In the third test case, Alice serves the ball and spends 11 stamina. Bob returns the ball and spends 11 stamina. Alice ran out of stamina, so she can't return the ball and loses the play. Bob, as a winner, serves the ball in the next 66 plays. Each time Alice can't return the ball and loses each play. The game is over with 00 Alice's and 77 Bob's wins.

Samples

3
1 1
2 1
1 7
0 1
1 1
0 7

在线编程 IDE

建议全屏模式获得最佳体验