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 <typename T>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "Yes" : "No");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
const int N = 32000000;
bitset<N + 5> bs;
vector<int> ps;
vector<long long> pks;
bool Ans[100005];
long long extend_gcd(long long a, long long b, long long &x, long long &y,
                     long long d) {
  if (b == 0) {
    x = d / a;
    y = 0;
    return a;
  } else {
    long long r = extend_gcd(b, a % b, y, x, d);
    y -= x * (a / b);
    return r;
  }
}
void init() {
  ps.push_back(2);
  for (int i = 3; i <= N; i += 2)
    if (!bs[i]) {
      ps.push_back(i);
      for (int j = i + i; j <= N; j += i) {
        bs[j] = 1;
      }
    }
}
long long p1, p2, G, pg1, pg2;
long long dis[100005];
bool used[100005];
void dij() {
  for (int(i) = 0; (i) < (int)(p1); (i)++) {
    dis[i] = (1LL << 60);
    used[i] = 0;
  }
  dis[0] = 0;
  priority_queue<pair<long long, int>, std::vector<pair<long long, int>>,
                 std::greater<pair<long long, int>>>
      q;
  q.push({0, 0});
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    if (used[x]) continue;
    used[x] = 1;
    for (auto p : pks) {
      long long d = p;
      int y = (x + p) % p1;
      if (dis[x] + d < dis[y]) {
        dis[y] = dis[x] + d;
        q.push({dis[y], y});
      }
    }
  }
}
void reinitK(long long k) {
  pks.clear();
  long long tk = k;
  for (int P : ps) {
    if ((long long)P * P > tk) break;
    if (tk % P == 0) {
      pks.push_back(P);
      while (tk % P == 0) tk /= P;
    }
  }
  if (tk != 1) pks.push_back(tk);
  if (pks.size() == 2) {
    p1 = pks[0];
    p2 = pks[1];
    G = gcd1(p1, p2);
    pg1 = p1 / G;
    pg2 = p2 / G;
  } else if (pks.size() > 2) {
    p1 = pks[0];
    dij();
  }
}
long long qn[100005], qk[100005];
void fmain(int ID) {
  init();
  scanf("%d", &n);
  long long pk = -1;
  vector<pair<long long, int>> vp;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%lld%lld", qn + i, qk + i);
    vp.push_back({qk[i], i});
  }
  sort(vp.begin(), vp.end());
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    int id = vp[i].second;
    if (qk[id] != pk) {
      reinitK(qk[id]);
      pk = qk[id];
    }
    if (qk[id] == 1)
      Ans[id] = 0;
    else if (pks.size() == 1)
      Ans[id] = qn[id] % pks[0] == 0;
    else if (pks.size() == 2) {
      if (qn[id] % G != 0) {
        Ans[id] = 0;
        continue;
      }
      long long x, y;
      extend_gcd(p1, p2, x, y, G);
      x %= pg2;
      if (x < 0) x += pg2;
      Ans[id] = ((qn[id] % p2) * x % p2) * p1 <= qn[id];
    } else {
      Ans[id] = dis[qn[id] % p1] <= qn[id];
    }
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++) puts(Ans[i] ? "YES" : "NO");
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}