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;
long long first, second;
long long ex_gcd(long long a, long long b) {
  if (!b) {
    first = 1, second = 0;
    return a;
  }
  long long d = ex_gcd(b, a % b);
  long long tmp = first;
  first = second;
  second = tmp - a / b * second;
  return d;
}
struct bignum {
  long long a[40];
  int l;
  bignum() {
    l = 0;
    memset(a, 0, sizeof(a));
  }
  bignum(long long n) {
    l = 0;
    memset(a, 0, sizeof(a));
    while (n) {
      a[l++] = n % 10;
      n /= 10;
    }
  }
  bignum mul(bignum p) {
    bignum c;
    for (int i = 0; i < l; i++) {
      for (int j = 0; j < p.l; j++) {
        c.a[i + j] += a[i] * p.a[j];
      }
    }
    c.l = l + p.l;
    for (int i = 0; i < c.l; i++) {
      if (c.a[i] >= 10) {
        c.a[i + 1] += c.a[i] / 10;
        c.a[i] %= 10;
      }
    }
    while (c.l && !c.a[c.l - 1]) c.l--;
    return c;
  }
  void div(long long p) {
    long long tmp = 0;
    for (int i = l - 1; i >= 0; i--) {
      long long first = (tmp * 10 + a[i]) % p;
      a[i] = (tmp * 10 + a[i]) / p;
      tmp = first;
    }
    while (l && !a[l - 1]) l--;
  }
  void add(int first) {
    a[0] += first;
    for (int i = 0; i < l; i++) {
      if (a[i] >= 10) {
        a[i + 1] += a[i] / 10;
        a[i] %= 10;
      }
    }
    if (a[l]) l++;
  }
};
bool check(long long p, long long q, long long n) {
  if (p > q) swap(p, q);
  if (n % p == 0 || n % q == 0) return true;
  if (n / q <= 2000) {
    for (int i = 0; i * q <= n; i++) {
      if ((n - i * q) % p == 0) return true;
    }
    return false;
  }
  ex_gcd(p, q);
  if (first > 0) swap(p, q), swap(first, second);
  first = -first;
  bignum t1(first);
  bignum t2(second);
  bignum _n(n);
  t1 = t1.mul(_n);
  t2 = t2.mul(_n);
  t1.div(q);
  t1.add(1);
  t2.div(p);
  if (t1.l > t2.l) return false;
  if (t1.l < t2.l) return true;
  for (int i = t1.l - 1; i >= 0; i--) {
    if (t1.a[i] == t2.a[i]) continue;
    return t1.a[i] < t2.a[i];
  }
  return true;
}
const int N = 10010;
bool ans[N];
pair<long long, pair<long long, int> > a[N];
const int MAXN = 40000000;
int min_p[MAXN];
int prime[MAXN / 15];
int tot;
void init() {
  for (int i = 2; i < MAXN; i++) {
    if (!min_p[i]) {
      min_p[i] = i;
      prime[tot++] = i;
    }
    for (int j = 0; prime[j] * i < MAXN && j < tot; j++) {
      int first = prime[j] * i;
      if (i % prime[j] == 0) {
        min_p[first] = min_p[i];
        break;
      } else {
        min_p[first] = prime[j];
      }
    }
  }
}
long long fac[55], cnt;
void factor(long long n) {
  cnt = 0;
  for (int i = 0; 1LL * prime[i] * prime[i] <= n; i++) {
    if (n % prime[i]) continue;
    while (n % prime[i] == 0) n /= prime[i];
    fac[cnt++] = prime[i];
  }
  if (n > 1) fac[cnt++] = n;
}
long long dis[N * 10];
bool vis[N * 10];
void spfa() {
  sort(fac, fac + cnt);
  for (int i = 0; i < fac[0]; i++) vis[i] = false, dis[i] = 1LL << 62;
  dis[0] = 0;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = false;
    for (int i = 0; i < cnt; i++) {
      int first = (u + fac[i]) % fac[0];
      if (dis[first] > dis[u] + fac[i]) {
        dis[first] = dis[u] + fac[i];
        if (!vis[first]) {
          vis[first] = true;
          q.push(first);
        }
      }
    }
  }
}
void solve(int l, int r) {
  if (a[l].first == 1) {
    return;
  }
  factor(a[l].first);
  if (cnt > 2) spfa();
  for (int i = l; i <= r; i++) {
    if (a[i].second.first == 1) {
      continue;
    }
    if (cnt == 1) {
      if (a[i].second.first % fac[0] == 0) ans[a[i].second.second] = true;
      continue;
    }
    if (cnt == 2) {
      if (check(fac[0], fac[1], a[i].second.first))
        ans[a[i].second.second] = true;
      continue;
    }
    if (dis[a[i].second.first % fac[0]] <= a[i].second.first)
      ans[a[i].second.second] = true;
  }
}
int main() {
  init();
  int t;
  scanf("%d", &t);
  for (int i = 1; i <= t; i++) {
    cin >> a[i].second.first >> a[i].first;
    a[i].second.second = i;
  }
  sort(a + 1, a + t + 1);
  int i = 1;
  while (i <= t) {
    int j = i;
    while (j <= t && a[j].first == a[i].first) j++;
    solve(i, j - 1);
    i = j;
  }
  for (int i = 1; i <= t; i++)
    if (ans[i])
      printf("YES\n");
    else
      printf("NO\n");
  return 0;
}