Problem: You are given a positive integer n. In one move, you can increase n by one (i.e. make n := n + 1). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 2 ⋅ 10^4) — the number of test cases. Then t test cases follow.

The only line of the test case contains two integers n and s (1 ≤ n ≤ 10^{18}; 1 ≤ s ≤ 162).

Output

For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.

Example

Input


5
2 1
1 1
500 4
217871987498122 10
100000000000000001 1


Output


8
0
500
2128012501878
899999999999999999

Solution (in JAVA):

Solution:

import java.io.*;
import java.util.*;

public class WhatIsThisBro {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static final long[] POWERS_OF_TEN = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000,
        1000000000, 10000000000L, 100000000000L, 1000000000000L, 10000000000000L, 100000000000000L,
        1000000000000000L, 10000000000000000L, 100000000000000000L, 1000000000000000000L };
private static final long[] POWERS_OF_TWO = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384,
        32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864,
        134217728, 268435456, 536870912, 1073741824, 2147483648L, 4294967296L, 8589934592L, 17179869184L,
        34359738368L, 68719476736L, 137438953472L, 274877906944L, 549755813888L, 1099511627776L, 2199023255552L,
        4398046511104L, 8796093022208L, 17592186044416L, 35184372088832L, 70368744177664L, 140737488355328L,
        281474976710656L, 562949953421312L, 1125899906842624L, 2251799813685248L, 4503599627370496L,
        9007199254740992L, 18014398509481984L, 36028797018963968L, 72057594037927936L, 144115188075855872L,
        288230376151711744L, 576460752303423488L, 1152921504606846976L, 2305843009213693952L,
        4611686018427387904L };

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    private static Long readLong() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return Long.parseLong(st.nextToken());
    }

    private static String readToken() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public static void main(String[] args) throws IOException {
        int T = readInt();
        while (T-- > 0)
            solve();
        pw.close();
    }

    private static void solve() throws IOException {
        String n = readToken();
        int s = readInt();
        long operations = 0;
        int[] nchars = new int[n.length()];
        int sum = 0;
        for (int i = 0; i < n.length(); i++) {
            int tempval = Character.getNumericValue(n.charAt(i));
            nchars[i] = tempval;
            sum += tempval;
        }
        for (int i = n.length() - 1; i > -1; i--) {
            if (sum <= s) {
                break;
            }
            // if (sum - nchars[i] + 1 <= s) {
            // nchars[i] = sum - s;
            // somevalue++;
            // }
            sum -= (nchars[i] - 1);
            operations += (10L - nchars[i]) * powerOfTen(n.length() - 1 - i);
            if (i != 0) {
                nchars[i - 1]++;
            }
        }
        pw.println(operations);
    }

    private static long powerOfTen(int degree) {
        return POWERS_OF_TEN[degree];
    }

    private static long powerOfTwo(int degree) {
        return POWERS_OF_TWO[degree];
    }
}