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 euclid(long a, long b, long[] x, long[] y) {
        if (b == 0) {
            x[0] = 1;
            y[0] = 0;
            return a;
        }
        long d = a / b;
        long g = euclid(b, a - d * b, y, x);
        y[0] -= d * x[0];
        return g;
    }

    long multimod(long a, long b, long m) {
        boolean neg = false;
        if (a < 0) {
            a = -a;
            neg = !neg;
        }
        if (b < 0) {
            b = -b;
            neg = !neg;
        }
        long ans = 0;
        while (b > 0) {
            if ((b & 1) != 0) ans = (ans + a) % m;
            a = (a + a) % m;
            b >>>= 1;
        }
        if (neg) ans = (-ans) % m;
        return ans;
    }

    long[] diophantine(long a, long b, long x, long y, long g, long c) {
        if (c % g != 0) return null;
        long dx = c / a;
        c -= dx * a;
        long x0 = multimod(x, c / g, b / g);
        long y0 = (c - a * x0) / b;
        return new long[]{x0 + dx, y0};
    }

    void start() {
        boolean[] isp = new boolean[(int) (Math.sqrt(1e+15) + 1e3)];
        Arrays.fill(isp, true);
        for (int i = 2; i * i < isp.length; i++)
            if (isp[i]) for (int j = i + i; j < isp.length; j += i) isp[j] = false;
        List<Integer> ps = new ArrayList<>();
        for (int i = 2; i < isp.length; i++)
            if (isp[i]) ps.add(i);
        isp = null;

        Map<Long, List<Integer>> ks = new HashMap<>();
        int t = readInt();
        long[] ns = new long[t];
        for (int i = 0; i < t; i++) {
            ns[i] = readLong();
            ks.computeIfAbsent(readLong(), x -> new ArrayList<>()).add(i);
        }

        boolean[] ans = new boolean[t];
        for (long k : ks.keySet()) {
            List<Long> f = new ArrayList<>();
            long v = k;
            for (int p : ps)
                if (p * p > v) break;
                else if (v % p == 0) {
                    f.add((long) p);
                    do v /= p;
                    while (v % p == 0);
                }
            if (v > 1) f.add(v);
            if (f.size() == 0) continue;

            if (f.size() == 1) {
                // p = k;
                for (int i : ks.get(k))
                    if (ns[i] % k == 0) ans[i] = true;
                continue;
            }

            if (f.size() == 2) {
                long a = f.get(0), b = f.get(1);
                long[] ax = new long[1], by = new long[1];
                long g = euclid(a, b, ax, by);
                for (int i : ks.get(k)) {
                    long n = ns[i];
                    long[] xy = diophantine(a, b, ax[0], by[0], g, n);
                    if (xy == null) continue;
                    long x = xy[0], y = xy[1], bg = b / g, ag = a / g;
                    if (x > 0 && y < 0) {
                        long sub = x / bg;
                        long add = (-y + ag - 1) / ag;
                        if (sub >= add) y = 0;
                    }
                    if (y > 0 && x < 0) {
                        long sub = y / ag;
                        long add = (-x + bg - 1) / bg;
                        if (sub >= add) x = 0;
                    }
                    if (x >= 0 && y >= 0) ans[i] = true;
                }
                continue;
            }

            long p0 = f.get(0);
            long[] dist = new long[(int) p0];
            Arrays.fill(dist, 1, dist.length, Long.MAX_VALUE);
            PriorityQueue<long[]> q = new PriorityQueue<>((a, b) -> Long.compare(a[0], b[0]));
            q.offer(new long[]{0, 0});
            while (!q.isEmpty()) {
                long[] e = q.poll();
                long s = e[0];
                int r = (int) e[1];
                if (dist[r] != s) continue;
                for (long p : f) {
                    long sp = s + p;
                    int nr = (int) (sp % p0);
                    if (dist[nr] > sp) {
                        dist[nr] = sp;
                        q.offer(new long[]{sp, nr});
                    }
                }
            }

            for (int i : ks.get(k)) {
                int r = (int) (ns[i] % p0);
                if (ns[i] >= dist[r]) ans[i] = true;
            }
        }

        for (int i = 0; i < t; i++)
            writer.println(ans[i] ? "YES" : "NO");
    }

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