Problem: Surely you have seen insane videos by South Korean rapper PSY, such as "Gangnam Style", "Gentleman" and "Daddy". You might also hear that PSY has been recording video "Oppa Funcan Style" two years ago (unfortunately we couldn't find it on the internet). We will remind you what this hit looked like (you can find original description [here](http://acm.timus.ru/problem.aspx?space=1&num=2107&locale=en)):

On the ground there are n platforms, which are numbered with integers from 1 to n, on i-th platform there is a dancer with number i. Further, every second all the dancers standing on the platform with number i jump to the platform with the number f(i). The moving rule f is selected in advance and is not changed throughout the clip.

The duration of the clip was k seconds and the rule f was chosen in such a way that after k seconds all dancers were in their initial positions (i.e. the i-th dancer stood on the platform with the number i). That allowed to loop the clip and collect even more likes.

PSY knows that enhanced versions of old artworks become more and more popular every day. So he decided to release a remastered-version of his video.

In his case "enhanced version" means even more insanity, so the number of platforms can be up to 10^{18}! But the video director said that if some dancer stays on the same platform all the time, then the viewer will get bored and will turn off the video immediately. Therefore, for all x from 1 to n f(x) ≠ x must hold.

Big part of classic video's success was in that looping, so in the remastered version all dancers should return to their initial positions in the end of the clip as well.

PSY hasn't decided on the exact number of platforms and video duration yet, so he asks you to check if there is a good rule f for different options.

Input

In the first line of input there is one integer t (1 ≤ t ≤ 10^{4}) — the number of options for n and k to check.

In the next t lines the options are given: each option is described with two integers n and k (1 ≤ n ≤ 10^{18}, 1 ≤ k ≤ 10^{15}) — the number of dancers and the duration in seconds.

It is guaranteed that the number of different values of k in one test is not greater than 50.

Output

Print t lines. If the i-th option of the video is feasible, print "YES" (without quotes) in i-th line, otherwise print "NO" (without quotes).

Example

Input

3
7 7
3 8
5 6


Output

YES
NO
YES

Solution (in JAVA):

Solution:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Test {

    static int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    static long readLong() {
        long ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    static String readString() {
        StringBuilder b = new StringBuilder();
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c >= '0' && c <= '9') {
                    start = true;
                    b.append((char) (c));
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return b.toString().trim();
    }

    static PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    long[] kp1 = new long[50];
    long[] kp2 = new long[50];
    long[][] xy = new long[50][2];
    long[][] bound = new long[50][];
    int K = 0;
    List<Integer> ps = new ArrayList<>();
    Map<Long, Integer> map = new HashMap<>();

    long[] euclid(long a, long b) {
        if (b == 0) return new long[]{1, 0};
        long[] xy = euclid(b, a % b);
        return new long[]{xy[1], xy[0] - (a/b)*xy[1]};
    }

    void go(long k) {
        map.put(k, K);
        long v = k;
        List<Long> f = new ArrayList<>();
        for (int p : ps)
            if (p*p > v) break;
            else if (v % p == 0) {
                f.add((long) p);
                while (v % p == 0) v /= p;
            }
        if (v == k) {
            kp1[K] = k;
            K++;
            return;
        }
        if (v > 1) f.add(v);
        if (f.size() == 2) {
            long a = f.get(0);
            long b = f.get(1);
            long[] e = euclid(a, b);
            kp1[K] = a;
            kp2[K] = b;
            xy[K] = e;
            K++;
            return;
        }
        int p1 = (int)((long)(f.get(0)));
        long[] min = new long[p1];
        Arrays.fill(min, -1);
        PriorityQueue<Long> q = new PriorityQueue<>();
        q.offer(0l);
        while (!q.isEmpty()) {
            long s = q.poll();
            int r = (int)(s % p1);
            if (min[r] >= 0) continue;
            min[r] = s;
            for (long p : f) q.offer(s + p);
        }
        kp1[K] = p1;
        bound[K] = min;
        K++;
    }

    void start() {
        boolean[] isp = new boolean[40_000_000];
        Arrays.fill(isp, true);
        for (int i = 2; i < isp.length; i++)
            if (isp[i]) for (int j = i + i; j < isp.length; j += i) isp[j] = false;
        for (int i = 2; i < isp.length; i++)
            if (isp[i]) ps.add(i);
        int t = readInt();
        while (t-- > 0) {
            long n = readLong(), k = readLong();
            if (k == 1) {
                writer.println("NO");
                continue;
            }
            if (!map.containsKey(k)) go(k);
            int idx = map.get(k);
            if (kp1[idx] == k) {
                if (n % k == 0) writer.println("YES");
                else writer.println("NO");
                continue;
            }
            if (kp2[idx] > 0) {
                long x = xy[idx][0], y = xy[idx][1], a = kp1[idx], b = kp2[idx];
                BigInteger bn = BigInteger.valueOf(n), bx = BigInteger.valueOf(x), by = BigInteger.valueOf(y),
                ba = BigInteger.valueOf(a), bb = BigInteger.valueOf(b);
                BigInteger bm = bn.multiply(by).divide(ba).add(BigInteger.ONE);
                boolean found = false;
                for (long i = 0; i <= 3; i++) {
                    BigInteger bmi = bm.subtract(BigInteger.valueOf(i));
                    if (bn.multiply(by).subtract(ba.multiply(bmi)).compareTo(BigInteger.ZERO) >= 0 &&
                            bn.multiply(bx).add(bb.multiply(bmi)).compareTo(BigInteger.ZERO) >= 0) {
                        writer.println("YES");
                        found = true;
                        break;
                    }
                }
                if (!found) writer.println("NO");
                continue;
            }
            long[] b = bound[idx];
            int r = (int)(n % kp1[idx]);
            if (b[r] != -1 && n >= b[r]) writer.println("YES");
            else writer.println("NO");
        }
    }

    public static void main(String[] args) {
        Test te = new Test();
        te.start();
        writer.flush();
    }
}