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 <class T>
inline void in(T &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c)) f |= (c == '-'), c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ '0'), c = getchar();
  f ? x = -x : 0;
}
template <class T>
inline void out(T x, const char c = '\n') {
  static short st[30];
  short m = 0;
  if (x < 0) putchar('-'), x = -x;
  do st[++m] = x % 10, x /= 10;
  while (x);
  while (m) putchar(st[m--] | '0');
  putchar(c);
}
template <class T>
inline void err(const T &x, const char c = '\n') {
  cerr << x << c;
}
template <class T, class... Args>
inline void in(T &x, Args &...args) {
  in(x);
  in(args...);
}
template <class T, class... Args>
inline void out(const T &x, const Args &...args) {
  out(x, ' ');
  out(args...);
}
template <class T, class... Args>
inline void err(const T &x, const Args &...args) {
  err(x, ' ');
  err(args...);
}
template <class T>
inline void prt(T a[], int n) {
  for (register int i = 0; i < n; ++i) out(a[i], i == n - 1 ? '\n' : ' ');
}
template <class T>
inline void clr(T a[], int n) {
  memset(a, 0, sizeof(T) * n);
}
template <class T>
inline void clr(T *a, T *b) {
  memset(a, 0, sizeof(T) * (b - a));
}
template <class T>
inline bool ckmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
inline bool ckmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
namespace i207M {
bitset<31622777> notp;
int pri[2000000], cntp;
void sieve(int n) {
  notp[1] = 1;
  for (register int i = 2; i <= n; ++i) {
    if (!notp[i]) pri[++cntp] = i;
    for (register int j = 1, t; j <= cntp && (t = pri[j] * i) <= n; ++j) {
      notp[t] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
bool ans[10005];
vector<long long> d;
void divi(long long x) {
  d.clear();
  for (register int i = 1; i <= cntp && (long long)pri[i] * pri[i] <= x; ++i)
    if (x % pri[i] == 0) {
      d.push_back(pri[i]);
      while (x % pri[i] == 0) x /= pri[i];
    }
  if (x > 1) d.push_back(x);
}
inline long long qmul(const long long &a, const long long &b,
                      const long long &md) {
  long long c = a * b - (long long)((long double)a * b / md + 0.5) * md;
  return c < 0 ? c + md : c;
}
inline long long qpow(long long a, long long b, const long long &md) {
  long long r = 1;
  for (; b; b >>= 1, a = qmul(a, a, md))
    if (b & 1) r = qmul(r, a, md);
  return r;
}
void solve(long long K, const vector<pair<long long, int> > &Q) {
  if (K == 1) return;
  divi(K);
  if (((int)d.size()) == 1) {
    long long t = d[0];
    for (const auto &it : Q) ans[it.second] = (it.first % t == 0);
    return;
  }
  if (((int)d.size()) == 2) {
    long long a = d[0], b = d[1];
    for (const auto &it : Q) {
      long long n = it.first;
      if (n % a == 0 || n % b == 0) {
        ans[it.second] = 1;
        continue;
      }
      long long y = qmul(n % a, qpow(b, a - 2, a), a);
      ans[it.second] = (b * y <= n && (n - b * y) % a == 0);
    }
    return;
  }
  static long long dis[100005];
  static bool ins[100005];
  static queue<int> q;
  memset(dis, 0x3f, sizeof(dis));
  q.push(0), dis[0] = 0;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    ins[x] = 0;
    for (register int i = 1; i < ((int)d.size()); ++i) {
      int v = (x + d[i]) % d[0];
      if (ckmin(dis[v], dis[x] + d[i]) && !ins[v]) q.push(v), ins[v] = 1;
    }
  }
  for (const auto &it : Q) ans[it.second] = (dis[it.first % d[0]] <= it.first);
}
map<long long, vector<pair<long long, int> > > rem;
signed main() {
  int T;
  long long a, b;
  in(T);
  sieve(31622776);
  for (register int i = 1; i <= T; ++i) {
    in(a, b);
    rem[b].push_back(make_pair(a, i));
  }
  for (const auto &it : rem) solve(it.first, it.second);
  for (register int i = 1; i <= T; ++i) puts(ans[i] ? "YES" : "NO");
  return 0;
}
}  // namespace i207M
signed main() {
  i207M::main();
  return 0;
}