• # For Solution

It is a simplified version of problem F2. The difference between them is the constraints (F1: k2k≤2, F2: k10k≤10).

You are given an integer nn. Find the minimum integer xx such that xnx≥n and the number xx is kkbeautiful.

A number is called kkbeautiful if its decimal representation having no leading zeroes contains no more than kk different digits. E.g. if k=2k=2, the numbers 343444334344435555055550777777 and 2121 are kkbeautiful whereas the numbers 120120445435445435 and 998244353998244353 are not.

Input

The first line contains one integer tt (1t1041≤t≤104) — the number of test cases. Then tt test cases follow.

Each test case consists of one line containing two integers nn and kk (1n1091≤n≤1091k21≤k≤2).

Output Nearest Beautiful Number (easy version) solution codeforces

For each test case output on a separate line xx — the minimum kkbeautiful integer such that xnx≥n.

Example
input

Copy
4
1 1
221 2
177890 2
998244353 1

output

Copy
1
221
181111
999999999


Nearest Beautiful Number (easy version) solution codeforces

It is a simplified version of problem F2. The difference between them is the constraints (F1: k2k≤2, F2: k10k≤10).

You are given an integer nn. Find the minimum integer xx such that xnx≥n and the number xx is kkbeautiful.

A number is called kkbeautiful if its decimal representation having no leading zeroes contains no more than kk different digits. E.g. if k=2k=2, the numbers 343444334344435555055550777777 and 2121 are kkbeautiful whereas the numbers 120120445435445435 and 998244353998244353 are not.

Input

The first line contains one integer tt (1t1041≤t≤104) — the number of test cases. Then tt test cases follow.

Each test case consists of one line containing two integers nn and kk (1n1091≤n≤1091k21≤k≤2).

Output

For each test case output on a separate line xx — the minimum kkbeautiful integer such that xnx≥n.

Example
input

Copy
4
1 1
221 2
177890 2
998244353 1

output

Copy
1
221
181111
999999999


It is a simplified version of problem F2. The difference between them is the constraints (F1: k2k≤2, F2: k10k≤10).

You are given an integer nn. Find the minimum integer xx such that xnx≥n and the number xx is kkbeautiful.

A number is called kkbeautiful if its decimal representation having no leading zeroes contains no more than kk different digits. E.g. if k=2k=2, the numbers 343444334344435555055550777777 and 2121 are kkbeautiful whereas the numbers 120120445435445435 and 998244353998244353 are not.

Input

The first line contains one integer tt (1t1041≤t≤104) — the number of test cases. Then tt test cases follow.

Each test case consists of one line containing two integers nn and kk (1n1091≤n≤1091k21≤k≤2).

Output

For each test case output on a separate line xx — the minimum kkbeautiful integer such that xnx≥n.

Example
input

Copy
4
1 1
221 2
177890 2
998244353 1

output

Copy
1
221
181111
999999999