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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline long long Qmul(const long long &x, const long long &y,
                      const long long &X) {
  long long k = (long long)((1.0L * x * y) / (1.0L * X)), t = x * y - k * X;
  t -= X;
  while (t < 0) t += X;
  return t;
}
class MillerRabin {
 private:
  const int P[12] = {2, 3, 5, 7, 11, 13, 17, 19, 61, 2333, 4567, 24251};
  inline long long Qpow(long long x, long long y, long long X) {
    long long t = 1;
    while (y) y & 1 && (t = Qmul(t, x, X)), x = Qmul(x, x, X), y >>= 1;
    return t;
  }
  inline bool Check(const long long &x, const int &p) {
    if (!(x % p) || Qpow(p % x, x - 1, x) ^ 1) return false;
    long long k = x - 1, t;
    while (!(k & 1)) {
      if ((t = Qpow(p % x, k >>= 1, x)) ^ 1 && t ^ (x - 1)) return false;
      if (!(t ^ (x - 1))) return true;
    }
    return true;
  }

 public:
  bool IsPrime(const long long &x) {
    if (x < 2) return false;
    for (int i = 0; i ^ 12; ++i) {
      if (!(x ^ P[i])) return true;
      if (!Check(x, P[i])) return false;
    }
    return true;
  }
};
class PollardRho {
 private:
  long long ans;
  MillerRabin MR;
  inline long long gcd(const long long &x, const long long &y) {
    return y ? gcd(y, x % y) : x;
  }
  inline long long Work(const long long &x, const int &y) {
    int t = 0, k = 1;
    long long v0 = (1LL * rand() * rand() * rand() * rand() % (x - 1) + 1),
              v = v0, d, s = 1;
    while (1) {
      if (v = (Qmul(v, v, x) + y) % x,
          s = Qmul(s, ((v - v0) < 0 ? -(v - v0) : (v - v0)), x),
          !(v ^ v0) || !s)
        return x;
      if (++t == k) {
        if ((d = gcd(s, x)) ^ 1) return d;
        v0 = v, k <<= 1;
      }
    }
  }
  inline void Resolve(long long x, int t) {
    if (!(x ^ 1) || x <= ans) return;
    if (MR.IsPrime(x)) return (void)(ans < (x) && (ans = (x)));
    long long y = x;
    while ((y = Work(x, t--)) == x)
      ;
    while (!(x % y)) x /= y;
    Resolve(x, t), Resolve(y, t);
  }

 public:
  inline PollardRho() { srand(20050521); }
  inline long long GetMax(const long long &x) {
    return ans = 0, Resolve(x, 302627441), ans;
  }
} P;
int T, p, ans[10010];
long long pr[60], dis[100010], head[100010], o;
struct edge {
  int to, link;
  long long w;
} e[6000010];
struct node {
  int id;
  long long w;
  bool operator<(const node &b) const { return w > b.w; }
};
priority_queue<node> Q;
struct ask {
  long long n, k, id;
  bool operator<(const ask &b) const { return k < b.k; }
} q[10010];
void add_edge(int u, int v, long long w) {
  e[++o].to = v, e[o].link = head[u], head[u] = o, e[o].w = w;
}
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) return x = 1, y = 0, a;
  long long t = exgcd(b, a % b, y, x);
  return y -= a / b * x, t;
}
int main() {
  scanf("%d", &T);
  for (int i = 1; i <= T; i++) scanf("%lld%lld", &q[i].n, &q[i].k), q[i].id = i;
  sort(q + 1, q + T + 1);
  for (int l = 1, r = 0; l <= T; l = r + 1) {
    while (r < T && q[r + 1].k == q[l].k) r++;
    long long k = q[l].k;
    if (k == 1) continue;
    p = 0;
    while (k > 1) {
      pr[++p] = P.GetMax(k);
      while (k % pr[p] == 0) k /= pr[p];
    }
    if (p == 1) {
      for (int i = l; i <= r; i++) ans[q[i].id] = (q[i].n % pr[1] == 0);
      continue;
    }
    if (p == 2) {
      long long x, y;
      exgcd(pr[1], pr[2], x, y);
      x = (x % pr[2] + pr[2]) % pr[2];
      for (int i = l; i <= r; i++) {
        long long b = q[i].n - Qmul(x, q[i].n, pr[2]) * pr[1];
        ans[q[i].id] = (b >= 0);
      }
      continue;
    }
    int L = pr[p];
    o = 0;
    for (int i = 1; i < L; i++) dis[i] = LLONG_MAX;
    for (int i = 0; i < L; i++) {
      head[i] = 0;
      for (int j = 1; j < p; j++) add_edge(i, (i + pr[j]) % L, pr[j]);
    }
    Q.push((node){0, dis[0] = 0});
    while (Q.size()) {
      int u = Q.top().id;
      Q.pop();
      for (int i = head[u]; i; i = e[i].link)
        if (e[i].w + dis[u] < dis[e[i].to]) {
          dis[e[i].to] = dis[u] + e[i].w;
          Q.push((node){e[i].to, dis[e[i].to]});
        }
    }
    for (int i = l; i <= r; i++) ans[q[i].id] = (q[i].n >= dis[q[i].n % L]);
  }
  for (int i = 1; i <= T; i++) puts(ans[i] ? "YES" : "NO");
}