### Another Card Game Problem Problem Code: CRDGAME3

### Read problem statements in Hindi, Bengali, Mandarin Chinese, Russian, and Vietnamese as well.

Chef is playing a card game with his friend Rick Sanchez. He recently won against Rick's grandson Morty; however, Rick is not as easy to beat. The rules of this game are as follows:

- The
*power*of a positive integer is the sum of digits of that integer. For example, the power of is . - Chef and Rick receive randomly generated positive integers. For each player, let's call the integer he received
*final power*. - The goal of each player is to generate a positive integer such that its power (defined above) is equal to his final power.
- The player who generated the integer with fewer digits wins the game. If both have the same number of digits, then Rick cheats and wins the game.

You are given the final power of Chef and the final power of Rick . Assuming that both players play optimally, find the winner of the game and the number of digits of the integer he generates.

### Input

- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first and only line of each test case contains two space-separated integers and .

### Output

For each test case, print a single line containing two space-separated integers. The first of these integers should be either if Chef wins or if Rick wins. The second integer should be the number of digits of the integer generated by the winner.

### Constraints

### Subtasks

Subtask #1 (100 points): original constraints

### Example Input

```
3
3 5
28 18
14 24
```

### Example Output

```
1 1
1 2
0 2
```

### Explanation

Example case 1: Chef and Rick generate the optimal integers and respectively. Each of them has digit, so Rick cheats and wins the game.

Example case 2: Chef and Rick could generate e.g. and respectively. Since Rick's integer has digits and Chef cannot generate an integer with less than digits, Rick wins.

Example case 3: Chef and Rick could generate e.g. and respectively. Chef's integer has digits and Rick cannot generate an integer with less than digits, so Chef wins.

i am unable to understand the explaination vs sample output please explain

ReplyDelete