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>
int t;
struct item {
  int id;
  long long n, k;
  bool operator<(const item& it) const { return k < it.k; }
} items[10010];
bool ans[10010];
long long ps[100];
int pc;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void exgcd(long long a, long long b, long long& x, long long& y) {
  if (!b)
    x = 1, y = 0;
  else
    exgcd(b, a % b, y, x), y -= a / b * x;
}
long long rnd() {
  long long x = rand();
  x = x << 15 ^ rand();
  return x << 15 ^ rand();
}
unsigned long long mul(unsigned long long a, unsigned long long b,
                       unsigned long long p) {
  unsigned long long c = 0;
  for (; b; b >>= 13) (c += a * (b & 8191)) %= p, a = (a << 13) % p;
  return c;
}
unsigned long long pw(unsigned long long a, unsigned long long n,
                      unsigned long long p) {
  unsigned long long b = 1;
  for (; n; n >>= 1) n % 2 ? b = mul(b, a, p) : 1, a = mul(a, a, p);
  return b;
}
bool isp(long long x) {
  if (x < 4) return 1;
  if (x % 2 == 0) return 0;
  if (x == 46856248255981ll) return 0;
  const int a[5] = {2, 3, 7, 61, 24251};
  for (int i = 0; i < 5 && a[i] < x; i++) {
    long long y = x - 1, t, u;
    while (y % 2 == 0) y /= 2;
    for (t = pw(a[i], y, x); y < x; y *= 2, t = u)
      if ((u = mul(t, t, x)) == 1 && t != 1 && t != x - 1) return 0;
    if (t != 1) return 0;
  }
  return 1;
}
void fact(long long n) {
  for (; n % 2 == 0; n /= 2) ps[pc++] = 2;
  if (n == 1) return;
  if (isp(n)) {
    ps[pc++] = n;
    return;
  }
  for (long long x = rnd() % n, y = x, z;; x = y = rnd() % n) {
    z = rnd() % (n - 1) + 1;
    do {
      x = (mul(x, x, n) + z) % n;
      y = (mul(y, y, n) + z) % n;
      y = (mul(y, y, n) + z) % n;
      long long g = gcd(x > y ? x - y : y - x, n);
      if (g > 1 && g < n) {
        fact(g);
        fact(n / g);
        return;
      }
    } while (x != y);
  }
}
struct qitem {
  int v;
  long long d;
  bool operator<(const qitem& it) const { return d > it.d; }
};
long long dis[100010];
bool vis[100010];
void calc_sp() {
  for (int i = 0; i < ps[0]; i++) vis[i] = 0;
  std::priority_queue<qitem> Q;
  Q.push((qitem){0, 0});
  while (!Q.empty()) {
    qitem it = Q.top();
    Q.pop();
    if (vis[it.v]) continue;
    vis[it.v] = 1;
    dis[it.v] = it.d;
    for (int j = 0; j < pc; j++) {
      int t = (it.v + ps[j]) % ps[0];
      if (!vis[t]) Q.push((qitem){t, it.d + ps[j]});
    }
  }
}
int main() {
  srand(time(0));
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%lld%lld", &items[i].n, &items[i].k);
    items[i].id = i;
  }
  std::sort(items, items + t);
  for (int tl = 0, tr = 0; tl < t; tl = tr) {
    long long k = items[tl].k;
    pc = 0;
    fact(k);
    std::sort(ps, ps + pc);
    pc = std::unique(ps, ps + pc) - ps;
    if (pc > 2) calc_sp();
    for (; tr < t && items[tr].k == k; tr++) {
      int id = items[tr].id;
      long long n = items[tr].n;
      if (!pc)
        ans[id] = 0;
      else if (pc == 1)
        ans[id] = n % ps[0] == 0;
      else if (pc == 2) {
        long long x, y;
        exgcd(ps[0], ps[1], x, y);
        x = (x + ps[1]) % ps[1];
        x = mul(x, n % ps[1], ps[1]);
        ans[id] = ps[0] * x <= n;
      } else
        ans[id] = vis[n % ps[0]] && dis[n % ps[0]] <= n;
    }
  }
  for (int i = 0; i < t; i++) puts(ans[i] ? "YES" : "NO");
}