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;
int get() {
  char ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-') {
    int s = 0;
    while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
    return -s;
  }
  int s = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
  return s;
}
const int L = 32e6;
const int C = 1e4 + 5;
const int N = 1e5 + 5;
const long long INF = 1e12;
int P[3000005], u;
bool bz[L + 5];
void prepare() {
  for (int i = 2; i <= L; i++) {
    if (!bz[i]) P[++u] = i;
    for (int j = 1; j <= u; j++) {
      if (1ll * i * P[j] > L) break;
      bz[i * P[j]] = 1;
      if (i % P[j] == 0) break;
    }
  }
}
bool ans[C];
struct query {
  long long n, k;
  int id;
} qry[C];
bool cmp(query a, query b) { return a.k < b.k; }
long long pri[C];
int m;
long long dis[N];
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
struct status {
  int x;
  long long dis;
  status(const int x_ = 0, const long long dis_ = 0) {
    x = x_;
    dis = dis_;
  }
  friend bool operator<(status a, status b) {
    return a.dis != b.dis ? a.dis < b.dis : a.x < b.x;
  }
};
set<status> s;
long long quickmi(long long x, long long tim, long long mo) {
  long long ret = 1;
  for (; tim; tim /= 2, x = x * x % mo)
    if (tim & 1) ret = ret * x % mo;
  return ret;
}
void solve(int L, int R) {
  long long k = qry[L].k;
  if (k == 1) return;
  m = 0;
  int lim = sqrt(k);
  for (int i = 1; i <= u; i++) {
    if (1ll * P[i] * P[i] > k) break;
    if (k % P[i] == 0) {
      pri[++m] = P[i];
      while (k % P[i] == 0) k /= P[i];
    }
  }
  if (k > 1) pri[++m] = k;
  if (m == 1) {
    for (int i = L; i <= R; i++) ans[qry[i].id] = (qry[i].n % pri[1] == 0);
    return;
  }
  if (m == 2) {
    for (int i = L; i <= R; i++) {
      long long tmp = qry[i].n % pri[1] *
                      quickmi(pri[2] % pri[1], pri[1] - 2, pri[1]) % pri[1];
      ans[qry[i].id] = (qry[i].n >= tmp * pri[2]);
    }
    return;
  }
  int mo = pri[1];
  for (int i = 0; i <= mo - 1; i++) dis[i] = -1;
  dis[0] = 0;
  s.clear();
  s.insert(status(0, 0));
  while (s.begin() != s.end()) {
    int x = (*s.begin()).x;
    s.erase(s.begin());
    for (int i = 1; i <= m; i++) {
      int y = (x + pri[i]) % mo;
      if (dis[y] == -1 || dis[y] > dis[x] + pri[i]) {
        if (dis[y] != -1) s.erase(status(y, dis[y]));
        dis[y] = dis[x] + pri[i];
        s.insert(status(y, dis[y]));
      }
    }
  }
  for (int i = L; i <= R; i++) {
    if (dis[qry[i].n % mo] == -1)
      ans[qry[i].id] = 0;
    else
      ans[qry[i].id] = (qry[i].n >= dis[qry[i].n % mo]);
  }
}
int main() {
  prepare();
  int T = get();
  for (int i = 1; i <= T; i++) {
    qry[i].id = i;
    scanf("%I64d%I64d", &qry[i].n, &qry[i].k);
  }
  sort(qry + 1, qry + 1 + T, cmp);
  int lst = 0;
  for (int i = 1; i <= T; i++) {
    if (i == T || qry[i].k != qry[i + 1].k) {
      solve(lst + 1, i);
      lst = i;
    }
  }
  for (int i = 1; i <= T; i++)
    if (ans[i])
      printf("YES\n");
    else
      printf("NO\n");
  return 0;
}