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;
const int N = 10003, M = 31622800, K = 1952000, L = 100003;
template <typename T>
inline void read(T &x) {
  int ch = getchar();
  x = 0;
  bool f = false;
  for (; ch < '0' || ch > '9'; ch = getchar()) f |= ch == '-';
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
template <typename T>
inline bool chmin(T &a, const T &b) {
  if (a > b) return a = b, 1;
  return 0;
}
int t, m, pri[K], cnt, tot, head[L], to[L << 2], nxt[L << 2];
bool ans[N];
struct Query {
  int id;
  long long n, k;
  inline bool operator<(const Query &o) const {
    return k < o.k || k == o.k && id < o.id;
  }
} q[N];
bitset<M> notp;
long long p[N], dis[L], w[L << 2], x, y, d;
void init(int m) {
  notp[0] = notp[1] = 1;
  for (register int i = 2; i <= m; ++i) {
    if (!notp[i]) pri[tot++] = i;
    for (register int j = 0; j < tot && i * pri[j] <= m; ++j) {
      notp[i * pri[j]] = true;
      if (!(i % pri[j])) break;
    }
  }
}
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1;
    y = 0;
    d = a;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}
void add(int a, int b, long long c) {
  to[++cnt] = b;
  nxt[cnt] = head[a];
  head[a] = cnt;
  w[cnt] = c;
}
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    pq;
int main() {
  read(t);
  init(M - 1);
  for (register int i = 1; i <= t; ++i) {
    read(q[i].n);
    read(q[i].k);
    q[i].id = i;
  }
  sort(q + 1, q + t + 1);
  for (register int i = 1; i <= t; ++i) {
    if (q[i].k == 1) continue;
    if (q[i].k != q[i - 1].k) {
      m = 0;
      long long tmp = q[i].k;
      for (register int j = 0; j < tot && (long long)pri[j] * pri[j] <= tmp;
           ++j)
        if (!(tmp % pri[j])) {
          p[m++] = pri[j];
          tmp /= pri[j];
          while (!(tmp % pri[j])) tmp /= pri[j];
        }
      if (tmp > 1) p[m++] = tmp;
      if (m > 2) {
        memset(head, 0, sizeof head);
        cnt = 0;
        for (register int i = 1; i < m; ++i)
          for (register int j = 0; j < p[0]; ++j)
            add(j, (j + p[i]) % p[0], p[i]);
        memset(dis, 0x3f, sizeof dis);
        dis[0] = 0;
        pq.push(make_pair(0ll, 0));
        while (!pq.empty()) {
          pair<long long, long long> tmp = pq.top();
          pq.pop();
          if (tmp.first != dis[tmp.second]) continue;
          int u = tmp.second;
          for (register int i = head[u]; i; i = nxt[i])
            if (chmin(dis[to[i]], dis[u] + w[i]))
              pq.push(make_pair(dis[to[i]], to[i]));
        }
      } else if (m == 2) {
        exgcd(p[0], p[1], x, y);
        x = (x % p[1] + p[1]) % p[1];
      }
    }
    if (m > 2)
      ans[q[i].id] = dis[q[i].n % p[0]] <= q[i].n;
    else if (m == 2) {
      if (q[i].n % d) continue;
      q[i].n /= d;
      long long tmp = (q[i].n % p[1] * x % p[1] + p[1]) % p[1];
      ans[q[i].id] = tmp * p[0] <= q[i].n;
    } else
      ans[q[i].id] = !(q[i].n % p[0]);
  }
  for (register int i = 1; i <= t; ++i) puts(ans[i] ? "YES" : "NO");
}