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;
template <typename T>
void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
void chkmin(T &x, T y) {
  x = x > y ? y : x;
}
const long long INF = (1ull << 62);
template <typename T>
void read(T &x) {
  x = 0;
  bool f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = 0;
  } while (ch > '9' || ch < '0');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  x = f ? x : -x;
}
template <typename T>
void write(T x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int N = 1e4 + 5;
const int P = 4e6 + 5;
const int M = 31622776 + 5;
int T;
long long mx;
bool ans[N];
vector<int> frac;
int cnt, prime[P];
bool vis[M];
inline void init(int NN) {
  for (int i = 2; i <= NN; i++) {
    if (!vis[i]) {
      prime[++cnt] = i;
    }
    for (int j = 1; j <= cnt && i * prime[j] <= NN; j++) {
      vis[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
inline void calc(long long x) {
  frac.clear();
  for (int i = 1; 1ll * prime[i] * prime[i] <= x && i <= cnt; i++) {
    if (x % prime[i] == 0) {
      frac.push_back(prime[i]);
      while (x % prime[i] == 0) x /= prime[i];
    }
  }
  if (x != 1) frac.push_back(x);
}
struct QUERY {
  long long n, k, id;
} q[N];
inline bool cmp1(QUERY a, QUERY b) { return a.k < b.k; }
inline bool cmp2(QUERY a, QUERY b) { return a.id < b.id; }
inline long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long ret = exgcd(b, a % b, x, y);
  long long t = x;
  x = y;
  y = t - (a / b) * y;
  return ret;
}
inline void work(long long a, long long b, long long c, int id) {
  long long x, y, g;
  g = exgcd(a, b, x, y);
  if (c % g) {
    ans[id] = 0;
    return;
  }
  long long mod = b / g;
  x = (x % mod + mod) % mod;
  x = (c / g) % mod * x % mod;
  y = (c - x * a) / mod;
  ans[id] = y >= 0;
}
struct Node {
  long long u, d;
  Node(long long U = 0, long long D = 0) {
    u = U;
    d = D;
  }
  bool operator<(const Node &rhs) const { return d > rhs.d; }
};
long long dis[P];
inline void dijkstra() {
  for (int i = 0; i < frac[0]; i++) dis[i] = INF;
  priority_queue<Node> q;
  q.push(Node(0, 0));
  dis[0] = 0;
  while (!q.empty()) {
    Node t = q.top();
    q.pop();
    long long u = t.u, d = t.d;
    if (d != dis[u]) continue;
    for (int i = 1, sz = frac.size(); i < sz; i++) {
      long long v = (frac[i] + u) % frac[0], w = frac[i];
      if (dis[u] != INF && dis[v] > dis[u] + w) {
        dis[v] = dis[u] + w;
        q.push(Node(v, dis[v]));
      }
    }
  }
}
int main() {
  read(T);
  for (int i = 1; i <= T; i++) {
    read(q[i].n);
    read(q[i].k);
    q[i].id = i;
    mx = max(mx, q[i].k);
  }
  init(sqrt(mx));
  sort(q + 1, q + T + 1, cmp1);
  for (int i = 1; i <= T; i++) {
    int type = 0;
    if (q[i].k != q[i - 1].k) {
      frac.clear();
      calc(q[i].k);
      if (frac.size() > 2) dijkstra();
    }
    if (frac.size() == 0) {
      ans[q[i].id] = 0;
      continue;
    } else if (frac.size() == 1)
      ans[q[i].id] = (q[i].n % q[i].k == 0);
    else if (frac.size() == 2)
      work(frac[0], frac[1], q[i].n, q[i].id);
    else
      ans[q[i].id] = dis[q[i].n % frac[0]] <= q[i].n;
    ;
  }
  sort(q + 1, q + T + 1, cmp2);
  for (int i = 1; i <= T; i++) printf(ans[i] ? "YES\n" : "NO\n");
  return 0;
}