题目描述
Unfortunately someone has come and eaten the problem statement. Are you good enough to solve it without the statement?
Input
The first line contains T denoting the number of test cases.
The next T lines describe test cases and contain two integers each: N and M.
Output
For each test case output one integer - answer for the question.
Constraints
T ≤ 1000
1 ≤ N, M ≤ 10^9
Note:
N, M ≤ 1000 for 30% of the test
SAMPLE INPUT
6
28 1
39 1
90 1
15 2
123 2
114514 1919
SAMPLE OUTPUT
68
90
81
40
17
16
输入格式
见题面
输出格式
见题面
样例输入
6
28 1
39 1
90 1
15 2
123 2
114514 1919
SAMPLE
样例输出
68
90
81
40
17
16