You are given positive integers $N$ and $D$. You may perform operations of the following two types:
- add $D$ to $N$, i.e. change $N$ to $N+D$
- change $N$ to $\mathop{\mathrm{digitsum}}(N)$
Here, $\mathop{\mathrm{digitsum}}(x)$ is the sum of decimal digits of $x$. For example, $\mathop{\mathrm{digitsum}}(123)=1+2+3=6$, $\mathop{\mathrm{digitsum}}(100)=1+0+0=1$, $\mathop{\mathrm{digitsum}}(365)=3+6+5=14$.
You may perform any number of operations (including zero) in any order. Please find the minimum obtainable value of $N$ and the minimum number of operations required to obtain this value.

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

-----Output-----
For each test case, print a single line containing two space-separated integers — the minimum value of $N$ and the minimum required number of operations.

-----Constraints-----
- $1 \le T \le 10$
- $1 \le N, D \le 10^{10}$

-----Subtasks-----
Subtask #1 (30 points): $1 \le N, D \le 100$
Subtask #2 (70 points): original constraints

-----Example Input-----
3
2 1
9 3
11 13

-----Example Output-----
1 9
3 2
1 4

-----Explanation-----
Example case 1: The value $N=1$ can be achieved by 8 successive "add" operations (changing $N$ to $10$) and one "digit-sum" operation.
Example case 2: You can prove that you cannot obtain $N=1$ and $N=2$, and you can obtain $N=3$.
The value $N=3$ can be achieved by one "add" and one "digitsum" operation, changing $9$ to $12$ and $12$ to $3$.  
Example case 3: $N=1$ can be achieved by operations "add", "add", "digitsum", "digitsum": $11 \rightarrow 24 \rightarrow 37 \rightarrow 10 \rightarrow 1$.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'from collections import deque \r\nT=int(input())\r\ndef break_down(num):\r\n    count=0\r\n    while(len(num)!=1):\r\n        temp=0\r\n        for i in range(0,len(num)):\r\n            temp=temp+int(num[i])\r\n        num=str(temp)\r\n        count=count+1\r\n    return (int(num),count)\r\ndef digit_sum(num):\r\n    temp=0\r\n    for i in range(0,len(num)):\r\n        temp=temp+int(num[i])\r\n    num=temp\r\n    return (num)\r\nwhile(T):\r\n queue=deque()\r\n count_n=0\r\n count_d=0\r\n T=T-1\r\n N,d=[i for i in input().split()]\r\n n,count_n=break_down(N)\r\n D,count_D=break_down(d)\r\n dic={}\r\n if(D==1 or D==2 or D==4 or D==5 or D==7 or D==8):\r\n     mini=1 \r\n elif(D==3 or D==6):\r\n     mini=min(digit_sum(str(n+3)),digit_sum(str(n+6)),digit_sum(str(n+9)))\r\n else:\r\n     mini=n\r\n queue.append((int(N),0))\r\n ele=int(N)\r\n count=0\r\n while(len(queue)!=0):\r\n     ele,count=queue.popleft()\r\n     if(ele==mini):\r\n         break\r\n     else:\r\n         if(len(str(ele))==1):\r\n             temp1=ele+int(d)\r\n             queue.append((temp1,count+1))\r\n         else:\r\n             temp2=digit_sum(str(ele))\r\n             temp1=ele+int(d)\r\n             queue.append((temp2,count+1))\r\n             queue.append((temp1,count+1))\r\n print(ele,count)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14343