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>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using std::abs;
using std::cerr;
using std::cin;
using std::cout;
using std::map;
using std::max;
using std::min;
using std::pair;
using std::set;
using std::string;
using std::swap;
using std::vector;
using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned long long;
using ld = long double;
template <typename T>
void _dbg(const char *_s, T _h) {
  cerr << _s << " = " << _h << "\n";
}
template <typename T, typename... Ts>
void _dbg(const char *_s, T _h, Ts... _t) {
  int _b = 0;
  while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',') cerr << *_s++;
  cerr << " = " << _h << ",";
  _dbg(_s + 1, _t...);
}
struct init {
  init() {
    cin.tie(0);
    std::iostream::sync_with_stdio(0);
    cout << std::fixed << std::setprecision(10);
    cerr << std::fixed << std::setprecision(5);
  }
  ~init() {}
} init;
const int MAXN = 35e6;
const ll INF = 2e18;
int lp[MAXN];
int pr[2146775];
int cpr = 0;
void calc_primes(int n) {
  for (int i = 2; i <= n; ++i) {
    if (!lp[i]) {
      lp[i] = i;
      pr[cpr++] = i;
    }
    for (int j = 0; j < cpr && pr[j] <= lp[i] && i * pr[j] <= n; ++j)
      lp[i * pr[j]] = pr[j];
  }
}
vector<ll> fct(ll k) {
  ll x = k;
  vector<ll> res;
  for (int j = 0; j < cpr && pr[j] * 1LL * pr[j] <= k; ++j) {
    if (x % pr[j] == 0) {
      res.emplace_back(pr[j]);
      while (x % pr[j] == 0) x /= pr[j];
    }
  }
  if (x ^ 1LL) res.emplace_back(x);
  return res;
}
ll mulmod(ll a, ll b, ll m) {
  int sign = 1;
  if (a < 0) {
    a = -a;
    sign = -sign;
  }
  if (b < 0) {
    b = -b;
    sign = -sign;
  }
  a %= m;
  b %= m;
  ull q = (ld)a * (ld)b / (ld)m;
  ull r = a * b - q * m;
  return (sign * (ll)(((r + 5 * m) % m + m) % m)) % m;
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}
template <typename T>
bool diophant(T a, T b, T c, T &x, T &y, T &g) {
  if (a == 0 && b == 0) {
    if (c == 0) {
      x = y = g = 0;
      return true;
    }
    return false;
  }
  if (a == 0) {
    if (c % b == 0) {
      x = 0;
      y = c / b;
      g = abs(b);
      return true;
    }
    return false;
  }
  if (b == 0) {
    if (c % a == 0) {
      x = c / a;
      y = 0;
      g = abs(a);
      return true;
    }
    return false;
  }
  g = extgcd(a, b, x, y);
  if (c % g != 0) {
    return false;
  }
  T dx = c / a;
  c -= dx * a;
  T dy = c / b;
  c -= dy * b;
  x = dx + mulmod(x, c / g, b);
  y = dy + mulmod(y, c / g, a);
  g = abs(g);
  return true;
}
int32_t main() {
  calc_primes(MAXN - 1);
  ;
  int t;
  cin >> t;
  map<ll, vector<ll>> dv, dts;
  while (t--) {
    ll n, k;
    cin >> n >> k;
    if (dv.find(k) == dv.end()) dv[k] = fct(k);
    vector<ll> ps = dv[k];
    for (int i : ps)
      ;
    if (ps.empty())
      cout << "NO\n";
    else if (ps.size() == 1) {
      if (n % k == 0)
        cout << "YES\n";
      else
        cout << "NO\n";
    } else if (ps.size() == 2) {
      ll x, y, g;
      if (!diophant(ps[0], ps[1], n, x, y, g))
        cout << "NO\n";
      else {
        ;
        if (x < 0) {
          int bg = ps[1] / g;
          int need = (-x + bg - 1) / bg;
          x += bg * need;
          y -= ps[0] / g * need;
        }
        if (y < 0) {
          int ag = ps[0] / g;
          int need = (-y + ag - 1) / ag;
          y += ag / need;
          x -= ps[1] / g * need;
        }
        if (x >= 0 && y >= 0)
          cout << "YES\n";
        else
          cout << "NO\n";
      }
    } else {
      ;
      if (dts.find(k) == dts.end()) {
        vector<ll> d(ps[0], INF);
        d[0] = 0;
        set<pll> s;
        s.insert({0, 0});
        while (!s.empty()) {
          pll v = *s.begin();
          s.erase(s.begin());
          for (int i = 1; i < ps.size(); ++i) {
            ll to = (v.second + ps[i]) % ps[0];
            ll len = ps[i];
            if (d[to] > v.first + len) {
              s.erase({d[to], to});
              s.insert({d[to] = v.first + len, to});
            }
          }
        }
        dts[k] = d;
      }
      if (n >= dts[k][n % ps[0]])
        cout << "YES\n";
      else
        cout << "NO\n";
    }
  }
  return 0;
}