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;
int pri[9] = {2, 3, 5, 7, 11, 13, 15, 17, 23}, cnt = 0;
long long seed = 2001071221701002ll, ans[66];
inline long long rnd() {
  seed ^= (seed << 13ll);
  seed ^= (seed >> 17ll);
  seed ^= (seed << 5ll);
  return (seed < 0 ? -seed : seed);
}
inline void add(long long &a, long long b, long long p) {
  a = (a + b >= p ? a + b - p : a + b);
}
inline long long mul(long long a, long long b, long long p) {
  long long res = 0, tp = a;
  while (b) {
    if (b & 1ll) add(res, tp, p);
    add(tp, tp, p);
    b >>= 1ll;
  }
  return res;
}
inline long long qpow(long long a, long long b, long long mod) {
  a %= mod;
  long long res = 1, tp = a;
  while (b) {
    if (b & 1ll) res = mul(res, tp, mod);
    tp = mul(tp, tp, mod);
    b >>= 1ll;
  }
  return res;
}
inline long long gcd(long long a, long long b) {
  while (a % b) {
    long long t = a;
    a = b;
    b = t % b;
  }
  return b;
}
inline bool chk(long long n) {
  if (n <= 1) return false;
  long long now = n - 1;
  int cnt = 0, i, j;
  while (!(now & 1ll)) {
    now >>= 1ll;
    cnt++;
  }
  for (i = 0; i < 9; i++) {
    if (n == pri[i]) return true;
    if (n % pri[i] == 0) return false;
    long long m = qpow(pri[i], now, n), pre;
    for (j = 0; j < cnt; j++) {
      pre = m;
      m = mul(m, m, n);
      if (m == 1 && pre != 1 && pre != n - 1) return false;
    }
    if (m != 1) return false;
  }
  return true;
}
inline long long rho(long long n) {
  long long x = rnd() % (n - 1) + 1, y = x;
  long long c = rnd() % (n - 1) + 1, d;
  int i = 1, k = 2;
  while (1) {
    i++;
    x = mul(x, x, n) + c;
    if (x >= n) x -= n;
    if (x == y) return n;
    if (i > 4000000) return n;
    if (x > y) {
      d = gcd(x - y, n);
    } else {
      d = gcd(y - x, n);
    }
    if (d > 1 && d < n) return d;
    if (i == k) {
      y = x;
      k <<= 1;
    }
  }
}
void solve(long long n) {
  if (chk(n)) {
    ans[++cnt] = n;
    return;
  }
  long long p = rho(n);
  while (p == n) p = rho(n);
  solve(p);
  solve(n / p);
}
struct node {
  long long n, k;
  int id;
} t[10005];
bool res[10005];
inline bool cmp(node a, node b) { return a.k < b.k; }
long long dis[100005];
int o[66];
priority_queue<pair<long long, int> > q;
inline void work() {
  int i, sz = ans[1];
  for (i = 1; i <= cnt; i++) o[i] = ans[i] % sz;
  for (i = 0; i < sz; i++) dis[i] = (1ll << 60ll);
  dis[0] = 0;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    int id = q.top().second;
    long long d = -q.top().first;
    q.pop();
    if (dis[id] != d) continue;
    for (i = 2; i <= cnt; i++) {
      int np = (id + o[i] >= sz ? id + o[i] - sz : id + o[i]);
      if (dis[np] > dis[id] + ans[i]) {
        dis[np] = dis[id] + ans[i];
        q.push(make_pair(-dis[np], np));
      }
    }
  }
}
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}
int main() {
  srand(time(0));
  int T, i;
  scanf("%d", &T);
  for (i = 1; i <= T; i++) {
    scanf("%lld%lld", &t[i].n, &t[i].k);
    t[i].id = i;
  }
  sort(t + 1, t + T + 1, cmp);
  for (i = 1; i <= T; i++) {
    if (t[i].k == 1) continue;
    if (t[i].k != t[i - 1].k) {
      cnt = 0;
      solve(t[i].k);
      sort(ans + 1, ans + cnt + 1);
      cnt = unique(ans + 1, ans + cnt + 1) - ans - 1;
      if (cnt >= 3) work();
    }
    if (cnt == 1) {
      if (t[i].n % t[i].k == 0) res[t[i].id] = 1;
      continue;
    }
    if (cnt == 2) {
      long long x, y;
      exgcd(ans[1], ans[2], x, y);
      x = (x % ans[2] + ans[2]) % ans[2];
      x = mul(x, t[i].n % ans[2], ans[2]);
      if (x * ans[1] <= t[i].n) res[t[i].id] = 1;
      continue;
    }
    int bel = t[i].n % ans[1];
    if (t[i].n >= dis[bel]) res[t[i].id] = 1;
  }
  for (i = 1; i <= T; i++) puts(res[i] ? "YES" : "NO");
  return 0;
}