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.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;



public class Main {

    private static boolean[] brute_force(int k){
        int N = 20;
        boolean [] ret = new boolean[N + 1];
        ret[0] = true;
        for (int n = 1;n <= N;n++) {
            for (int x = 2;x <= k && x <= n && !ret[n];x++)
                if (k%x == 0)
                    ret[n] = ret[n - x];
        }
        return ret;
    }

    private static long [] N;
    private static int T;
    private static HashMap<Long,ArrayList<Integer> > HM = new HashMap<>();
    private static boolean [] ans;

    private static long x0,y0;
    private static void extendedEuclid(long a,long b) {
        if (b == 0) {
            x0 = 1;
            y0 = 0;
            return;
        }
        extendedEuclid(b,a%b);
        //x0*b + y0*(a - (a/b)*b) = d
        //x0*b + y0*a - y0*(a/b)*b = d
        long t = y0;
        y0 = x0 - y0*(a/b);
        x0 = t;
    }

    private static long [] D;
    private static void computeD(int P,ArrayList<Long> primes){
        D = new long[P];
        long [] dist = new long[P];
        for (int i = 0;i < P;i++)
            dist[i] = Long.MAX_VALUE / 2 - 10;
        dist[0] = 0;
        PriorityQueue<node> pq = new PriorityQueue<>();
        pq.add(new node(0,0));
        while (!pq.isEmpty()) {
            node cur = pq.poll();
            if (cur.d > dist[cur.u]) continue;
            for (long p : primes) {
                int x = (int)((cur.u + p)%P);
                if (cur.d + p < dist[x]) {
                    dist[x] = cur.d + p;
                    pq.add(new node(x,dist[x]));
                }
            }
        }
        D = dist;
    }

    private static ArrayList<Integer> smallPrimes = new ArrayList<>();
    private static void sieve(){
        int max = 31622777;
        boolean [] isComposite = new boolean[max+1];
        for (int p = 2;p <= max;p++)
            if (!isComposite[p]) {
                smallPrimes.add(p);
                for (long j = p*(long)p;j <= max;j += p)
                    isComposite[(int)j] = true;
            }
    }
    private static void solve(){
        ArrayList<Long> primes = new ArrayList<>();
        for (long k : HM.keySet()) {
            if (k == 1) continue;
            primes.clear();
            long v = k;
            for (int p : smallPrimes)
                if (v%p == 0) {
                    primes.add((long)p);
                    while (v%p == 0) v /= p;
                }
            if (v > 1) primes.add(v);
//            System.err.println(primes);
            if (primes.size() == 1) {
                long p = primes.get(0);
                for (int q : HM.get(k))
                    ans[q] = N[q]%p == 0;
            }
            else if (primes.size() == 2) {
                long a = primes.get(0),b = primes.get(1);
                for (int q : HM.get(k)) {
                    long n = N[q];
                    // a*x + b*y = n & x,y >= 0
                    extendedEuclid(a,b);

                    BigInteger x = BigInteger.valueOf(x0).multiply(BigInteger.valueOf(n));
                    BigInteger y = BigInteger.valueOf(y0).multiply(BigInteger.valueOf(n));
                    // x = x0 + t*b
                    // y = y0 - t*a
                    if (x0 >= 0 && y0 >= 0) ans[q] = true;
                    else if (x0 >= 0) {
                        BigInteger t = x.divide(BigInteger.valueOf(b));
                        BigInteger r = y.add(t.multiply(BigInteger.valueOf(a)));
                        ans[q] = r.compareTo(BigInteger.ZERO) >= 0;
                    }
                    else if (y0 >= 0) {
                        BigInteger t = y.divide(BigInteger.valueOf(a));
                        BigInteger r = x.add(t.multiply(BigInteger.valueOf(b)));
                        ans[q] = r.compareTo(BigInteger.ZERO) >= 0;
                    }
                }
            }
            else {
                long p = primes.get(0);
                computeD((int)p,primes);
                for (int q : HM.get(k))
                    ans[q] = N[q] >= D[(int)(N[q]%p)];
            }
        }
    }
    public static void main(String[] args) throws Exception {
        IO io = null;
        try{
            io = new IO("noureldin.in", null);
        }
        catch (IOException e) {
            io = new IO(null,null);
        }

        sieve();

        T = io.getNextInt();
        N = new long[T];
        ans = new boolean[T];
        for (int t = 0;t < T;t++) {
            N[t] = io.getNextLong();
            long k = io.getNextLong();
            if (!HM.containsKey(k))
                HM.put(k,new ArrayList<>());
            HM.get(k).add(t);
        }
        solve();

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


        io.close();
    }

    private static final int onebillion7 = 1000000007;
}

class node implements Comparable<node> {
    int u;
    long d;
    public node(int u,long d) {
        this.u = u;
        this.d = d;
    }
    @Override
    public int compareTo(node o) {
        if (d < o.d) return -1;
        if (d == o.d) return 0;
        return 1;
    }
}

class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public boolean hasMore() throws IOException{
        if(st != null && st.hasMoreTokens()) return true;
        if(br != null && br.ready()) return true;
        return false;
    }

    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine().trim();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
    public void outputArr(Object [] A) throws IOException{
        int L = A.length;
        for (int i = 0;i < L;i++) {
            if(i > 0) writer.print(" ");
            writer.print(A[i]);
        }
        writer.print("\n");
    }
}