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>
long long x, y;
const int maxn = 33333333;
bool flag[maxn + 100];
int prm[2222222], top;
void primer() {
  register int i, ii;
  for (i = 2; i <= maxn; i++)
    if (!flag[i]) {
      prm[++top] = i;
      for (ii = i; ii <= maxn / i; ii++) flag[i * ii] = 1;
    }
}
inline void exgcd(long long a, long long b) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a % b);
  long long t = x;
  x = y, y = t - (a / b) * y;
}
struct pii {
  long long x, k;
  int Id;
};
inline bool operator<(const pii x, const pii y) { return x.k < y.k; }
long long pr[11111];
int tpr;
inline bool split(long long x) {
  tpr = 0;
  for (register int i = 1; i <= top; i++)
    if (x % prm[i] == 0) {
      pr[++tpr] = prm[i];
      while (x % prm[i] == 0) x /= prm[i];
    }
  if (x > 1) pr[++tpr] = x;
  return tpr;
}
pii arg[11111];
bool ans[11111];
long long lst = -1;
struct edg {
  int p, t, l;
} e[2222222];
int h[111111], tot;
inline void build(int x, int y, int l) {
  e[++tot] = (edg){h[x], y, l}, h[x] = tot;
}
long long dis[111111];
bool vis[111111];
struct piii {
  int x;
  long long v;
};
inline bool operator<(const piii x, const piii y) { return x.v > y.v; }
std::priority_queue<piii> q;
void dij(int S) {
  register int i;
  memset(dis, 0x3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  dis[S] = 0;
  q.push((piii){S, 0});
  while (q.size()) {
    int p = q.top().x;
    q.pop();
    if (vis[p]) continue;
    vis[p] = 1;
    for (i = h[p]; i; i = e[i].p) {
      int to = e[i].t;
      if (dis[to] > dis[p] + e[i].l)
        dis[to] = dis[p] + e[i].l, q.push((piii){to, dis[to]});
    }
  }
}
inline long long mul(long long x, long long y, long long p) {
  long long s = 0;
  for (; y; y >>= 1, (x += x) %= p)
    if (y & 1) (s += x) %= p;
  return s;
}
void query(long long k, long long n, int Id) {
  long long g;
  if (k == 1) {
    ans[Id] = 0;
    return;
  }
  if (lst ^ k) split(k);
  if (tpr == 1)
    ans[Id] = (n % pr[1] == 0);
  else if (tpr == 2) {
    exgcd(pr[1], pr[2]), g = (x % pr[2] + pr[2]) % pr[2], g = mul(g, n, pr[2]);
    if (g > n / pr[1])
      ans[Id] = 0;
    else
      ans[Id] = 1;
  } else {
    memset(h, 0, sizeof(h)), tot = 0;
    if (lst ^ k) {
      register int i, ii;
      for (i = 0; i < pr[1]; i++)
        for (ii = 2; ii <= tpr; ii++) build(i, (i + pr[ii]) % pr[1], pr[ii]);
      dij(0);
    }
    ans[Id] = dis[n % pr[1]] <= n;
  }
  lst = k;
}
int qq;
int main() {
  scanf("%d", &qq);
  primer();
  register int i;
  for (i = 1; i <= qq; i++)
    scanf("%lld%lld", &arg[i].x, &arg[i].k), arg[i].Id = i;
  std::sort(arg + 1, arg + qq + 1);
  for (i = 1; i <= qq; i++) query(arg[i].k, arg[i].x, arg[i].Id);
  for (i = 1; i <= qq; i++) puts(ans[i] ? "YES" : "NO");
}