CF1328A.Divisibility Problem

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

Divisibility Problem

You are given two positive integers aa and bb. In one move you can increase aa by 11 (replace aa with a+1a+1). Your task is to find the minimum number of moves you need to do in order to make aa divisible by bb. It is possible, that you have to make 00 moves, as aa is already divisible by bb. You have to answer tt independent test cases.

Input

The first line of the input contains one integer tt (1t1041 \le t \le 10^4) — the number of test cases. Then tt test cases follow.

The only line of the test case contains two integers aa and bb (1a,b1091 \le a, b \le 10^9).

Output

For each test case print the answer — the minimum number of moves you need to do in order to make aa divisible by bb.

Samples

5
10 4
13 9
100 13
123 456
92 46
2
5
4
333
0

在线编程 IDE

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