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 read(T &x) {
  x = 0;
  bool f = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 1;
  for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  if (f) x = -x;
}
template <typename F>
inline void write(F x, char ed = '\n') {
  static short st[30];
  short tp = 0;
  if (x < 0) putchar('-'), x = -x;
  do st[++tp] = x % 10, x /= 10;
  while (x);
  while (tp) putchar('0' | st[tp--]);
  putchar(ed);
}
template <typename T>
inline void Mx(T &x, T y) {
  x < y && (x = y);
}
template <typename T>
inline void Mn(T &x, T y) {
  x > y && (x = y);
}
const int Maxn = 32000000;
const int Pim = 30000000;
const int N = 200050;
int e[Maxn + 55], prime[Pim], tot;
struct node {
  long long n, k;
  int num;
  bool operator<(const node &i) const { return k < i.k; }
} qy[N];
void prework(void) {
  for (int i = 2; i <= Maxn; i++) {
    if (!e[i]) prime[++tot] = e[i] = i;
    for (int j = 1; j <= tot; j++) {
      int t = prime[j] * i;
      if (t > Maxn) break;
      e[t] = prime[j];
      if (e[i] == prime[j]) break;
    }
  }
}
long long st[N], dis[N], tp;
int vis[N];
priority_queue<pair<long long, int> > q;
void work(long long k) {
  tp = 0;
  for (int i = 1, t; (long long)prime[i] * prime[i] <= k; i++) {
    if (k % (t = prime[i])) continue;
    st[++tp] = t;
    while (k % t == 0) k /= t;
  }
  if (k != 1) st[++tp] = k;
  memset(dis, 0x3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  if (tp == 2) swap(st[1], st[2]);
  if (tp >= 3) {
    dis[0] = 0, q.push(make_pair(0, 0));
    while (q.size()) {
      int x = q.top().second;
      q.pop();
      if (vis[x]) continue;
      vis[x] = 1;
      for (int i = 2; i <= tp; i++) {
        int y = (x + st[i]) % st[1];
        long long t = (x + st[i]) / st[1];
        if (dis[y] > dis[x] + t)
          dis[y] = dis[x] + t, q.push(make_pair(-dis[y], y));
      }
    }
  }
}
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) return x = 1, y = 0, void();
  exgcd(b, a % b, x, y);
  long long t = x;
  x = y, y = t - a / b * y;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
bool solve(long long n) {
  if (!tp) return 0;
  if (tp == 1) return n % st[1] == 0;
  if (tp == 2) {
    long long t1 = st[1], t2 = st[2], x, y;
    exgcd(t1, t2, x, y);
    x = (x % t2 + t2) % t2;
    long long tt = n % t2;
    x = x * tt % t2;
    return n >= x * t1;
  }
  return n >= dis[n % st[1]] * st[1] + (n % st[1]);
}
int ans[N], T;
int main() {
  read(T), prework();
  for (int i = 1; i <= T; i++) read(qy[i].n), read(qy[i].k), qy[i].num = i;
  sort(qy + 1, qy + T + 1);
  for (int l = 1, r; l <= T; l = r + 1) {
    work(qy[l].k), r = l;
    while (qy[r + 1].k == qy[l].k) r++;
    for (int i = l; i <= r; i++) ans[qy[i].num] = solve(qy[i].n);
  }
  for (int i = 1; i <= T; i++) puts(ans[i] ? "YES" : "NO");
  return 0;
}