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;
const long long inf = 1e18;
const int maxt = 10010;
const int maxn = 100010;
int T;
long long q_n[maxt], q_k[maxt];
int p_list[10000010], isnp[40000010], tot;
vector<long long> vec;
map<long long, int> k_id;
long long mul(long long a, long long b, long long mod) {
  long long ret = 0;
  for (int i = 0; i < 63; i++) {
    if ((a >> i) & 1) ret = (ret + b) % mod;
    b = b * 2 % mod;
  }
  return ret;
}
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long qpow(long long x, long long y, long long mod) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = 1LL * ret * x % mod;
    x = 1LL * x * x % mod;
    y >>= 1;
  }
  return ret;
}
void _find(long long n, vector<long long> &vec) {
  for (int i = 1; i <= tot; i++) {
    while (n % p_list[i] == 0) {
      vec.push_back(p_list[i]);
      n /= p_list[i];
    }
  }
  if (n > 1) vec.push_back(n);
}
struct ShortestPath {
  long long k, minp;
  int ps;
  stack<long long> st;
  vector<long long> prm;
  long long dis[maxn];
  void init() {
    minp = 2e18;
    if (k > 1) _find(k, prm);
    for (int i = 0; i < prm.size(); i++) minp = min(minp, prm[i]);
    ps = int(prm.size());
    sort(prm.begin(), prm.end());
    prm.erase(unique(prm.begin(), prm.end()), prm.end());
    if (ps >= 3) {
      for (int i = 0; i < minp; i++) {
        dis[i] = 2e18;
      }
      dis[0] = 0;
      priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                     greater<pair<long long, int> > >
          pq;
      pq.push(pair<long long, int>(dis[0], 0));
      while (!pq.empty()) {
        int u = pq.top().second;
        pq.pop();
        for (int i = 0; i < prm.size(); i++) {
          long long p = prm[i];
          int v = (u + p) % minp;
          if (dis[u] + p < dis[v]) {
            dis[v] = dis[u] + p;
            pq.push(pair<long long, int>(dis[v], v));
          }
        }
      }
    }
  }
  int query(long long n) {
    if (ps == 0) {
      return 0;
    } else if (ps == 1) {
      return (n % prm[0] == 0);
    } else if (ps == 2) {
      long long p1 = prm[0], p2 = prm[1];
      if (p1 == p2) return (n % p1 == 0);
      if (p1 == minp) swap(p1, p2);
      long long r = n % p1;
      long long t = qpow(p2, p1 - 2, p1);
      long long k = mul(r, t, p1);
      return k * p2 <= n;
    } else {
      return (dis[n % minp] <= n);
    }
  }
} shortestPath[55];
int main() {
  for (int i = 2; i <= 40000000; i++) {
    if (!isnp[i]) {
      p_list[++tot] = i;
    }
    for (int j = 1; j <= tot && p_list[j] * i <= 40000000; j++) {
      isnp[p_list[j] * i] = 1;
      if (i % p_list[j] == 0) break;
    }
  }
  cin >> T;
  for (int i = 1; i <= T; i++) {
    cin >> q_n[i] >> q_k[i];
    vec.push_back(q_k[i]);
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for (int i = 0; i < vec.size(); i++) {
    k_id[vec[i]] = i;
    shortestPath[i].k = vec[i];
    shortestPath[i].init();
  }
  for (int i = 1; i <= T; i++) {
    int id = k_id[q_k[i]];
    if (shortestPath[id].query(q_n[i]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}