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 long long maxn = 100010, inf = 1e9;
map<long long, long long> mp;
struct poi {
  long long x;
  long long dis;
};
priority_queue<poi> q;
bool operator<(poi a, poi b) { return a.dis > b.dis; }
struct edge {
  long long too;
  long long dis;
  long long pre;
} e[maxn * 15];
struct que {
  long long pos;
  long long w;
};
vector<que> v[maxn];
long long n, T, tot, K, tott, pcnt;
long long last[maxn], ans[maxn], prime[10000000];
long long dist[maxn], pri[maxn], pos[maxn];
bool vis[32000000];
template <typename T>
inline void read(T &k) {
  long long f = 1;
  k = 0;
  char c = getchar();
  while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
  while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
  k *= f;
}
inline long long power(long long a, long long b, long long mod) {
  long long ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) ans = 1ll * a * ans % mod;
  return ans;
}
inline void add(long long x, long long y, long long z) {
  e[++tot] = (edge){y, z, last[x]};
  last[x] = tot;
}
inline void dij(long long s) {
  memset(dist, 0x3f, sizeof(dist));
  dist[s] = 0;
  q.push((poi){s, dist[s]});
  while (!q.empty()) {
    poi now = q.top();
    q.pop();
    if (now.dis != dist[now.x]) continue;
    for (long long i = last[now.x], too; i; i = e[i].pre)
      if (dist[too = e[i].too] > dist[now.x] + e[i].dis) {
        dist[too] = dist[now.x] + e[i].dis;
        q.push((poi){too, dist[too]});
      }
  }
}
inline void getpri(long long n) {
  for (long long i = 2; i <= n; i++) {
    if (!vis[i]) prime[++pcnt] = i;
    for (long long j = 1; prime[j] * i <= n; j++) {
      vis[prime[j] * i] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
signed main() {
  read(T);
  getpri(sqrt(1e15));
  for (long long i = 1; i <= T; i++) {
    read(n);
    read(K);
    if (!mp.count(K)) mp[K] = ++tott, pos[tott] = K;
    v[mp[K]].push_back((que){i, n});
  }
  for (long long i = 1; i <= tott; i++) {
    long long x = pos[i];
    long long cnt = 0;
    for (long long j = 1; 1ll * prime[j] * prime[j] <= x && j <= pcnt; j++)
      if (x % prime[j] == 0) {
        pri[++cnt] = prime[j];
        while (x % prime[j] == 0) x /= prime[j];
      }
    if (x != 1) pri[++cnt] = x;
    if (!cnt)
      for (long long j = 0; j < v[i].size(); j++) ans[v[i][j].pos] = 0;
    else if (cnt == 1) {
      for (long long j = 0; j < v[i].size(); j++)
        ans[v[i][j].pos] = (v[i][j].w % pri[1] == 0);
    } else if (cnt == 2) {
      long long inv = power(pri[1], pri[2] - 2, pri[2]);
      for (long long j = 0; j < v[i].size(); j++)
        ans[v[i][j].pos] =
            (1ll * pri[1] * (1ll * inv * (v[i][j].w % pri[2]) % pri[2]) <=
             v[i][j].w);
    } else {
      tot = 0;
      memset(last, 0, sizeof(last));
      for (long long j = 0; j < pri[1]; j++) {
        for (long long k = 1; k <= cnt; k++)
          add(j, (j + pri[k]) % pri[1], pri[k]);
      }
      dij(0);
      for (long long j = 0; j < v[i].size(); j++)
        ans[v[i][j].pos] = (dist[v[i][j].w % pri[1]] <= v[i][j].w);
    }
  }
  for (long long i = 1; i <= T; i++) puts(ans[i] ? "YES" : "NO");
}