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 S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T& v : vc) o << v << ",";
  o << "]";
  return o;
}
using ll = long long;
const ll ccc = 32000000;
bool prime[ccc + 1];
vector<ll> pr;
void makeprime() {
  ll i, j;
  for (i = 2; i <= ccc; i++) prime[i] = true;
  for (i = 2; i * i <= ccc; i++)
    if (prime[i])
      for (j = 2; j * i <= ccc; j++) prime[j * i] = false;
  for (i = 2; i <= ccc; i++)
    if (prime[i]) pr.push_back(i);
}
ll extgcd(ll a, ll b, ll& x, ll& y) {
  ll u[] = {a, 1, 0}, v[] = {b, 0, 1};
  while (*v) {
    ll t = *u / *v;
    for (int i = 0; i < (int)(3); i++) swap(u[i] -= t * v[i], v[i]);
  }
  if (u[0] < 0)
    for (int i = 0; i < (int)(3); i++) u[i] = -u[i];
  x = u[1], y = u[2];
  return u[0];
}
ll inv(ll a, ll mod) {
  ll x, y;
  extgcd(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
const ll inf = 2e18;
vector<ll> dp;
bool solve(ll n, const vector<ll>& vs) {
  int K = vs.size();
  if (K == 0) return 0;
  if (K == 1) return n % vs[0] == 0;
  if (K == 2) {
    ll a = vs[1], b = vs[0];
    ll x = n % b * inv(a, b) % b;
    ll y = (n - a * x) / b;
    return a * x <= n;
  }
  return n >= dp[n % vs[0]];
}
void precalc(vector<ll> vs) {
  ll a = vs[0];
  dp = vector<ll>(a, inf);
  dp[0] = 0;
  using P = pair<ll, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  que.push(P(0, 0));
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    ll c = p.first;
    if (dp[v] != c) continue;
    for (ll x : vs) {
      int u = (v + x) % a;
      if (dp[u] > dp[v] + x) {
        dp[u] = dp[v] + x;
        que.push(P(dp[u], u));
      }
    }
  }
}
int main() {
  makeprime();
  int T;
  cin >> T;
  map<ll, vector<pair<ll, int>>> k2nt;
  for (int t = 0; t < (int)(T); t++) {
    ll n, k;
    cin >> n >> k;
    k2nt[k].push_back(make_pair(n, t));
  }
  vector<bool> ans(T);
  for (auto it : k2nt) {
    ll k = it.first;
    auto vnt = it.second;
    vector<ll> ps;
    ll ok = k;
    for (ll p : pr)
      if (k % p == 0) {
        ps.push_back(p);
        while (k % p == 0) k /= p;
      }
    if (k > 1) ps.push_back(k);
    k = ok;
    int A = ps.size();
    if (A >= 3) {
      precalc(ps);
    }
    for (auto p : vnt) {
      ll n = p.first;
      int t = p.second;
      ans[t] = solve(n, ps);
    }
  }
  for (int t = 0; t < (int)(T); t++) {
    if (ans[t])
      puts("YES");
    else
      puts("NO");
  }
}