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 int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 3e6 + 7;
const double pi = acos(-1.0);
const double eps = 0.00000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a = (long long)a * a % M)
    if (b & 1) ret = (long long)ret * a % M;
  return ret;
}
template <typename T>
inline T powMM(T a, T b, T M) {
  T ret = 1;
  for (; b; b >>= 1ll, a = (long long)a * a % M)
    if (b & 1) ret = (long long)ret * a % M;
  return ret;
}
const int maxsqrtk = 3.5e7 + 7;
int p[maxsqrtk], cntp;
void initfactor() {
  int i, j;
  for (i = 2; i < maxsqrtk; i++) {
    if (!p[i]) p[cntp++] = i;
    for (j = 0; j < cntp; j++) {
      if (i * p[j] >= maxsqrtk) break;
      p[i * p[j]] = 1;
      if (i % p[j] == 0) break;
    }
  };
}
const int maxk = 57;
vector<long long> minvalue[maxk], factor[maxk];
long long kth[maxk], cntk;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               less<pair<long long, long long> > >
    Q;
int TaskA() {
  int i, id;
  long long n, k;
  scanf("%I64d%I64d", &n, &k);
  for (id = 0; id < cntk; id++)
    if (kth[id] == k) break;
  if (cntk == id) {
    ;
    kth[cntk++] = k;
    for (i = 0; i < cntp; i++) {
      if (p[i] > k / p[i]) break;
      if (k % p[i] == 0) factor[id].push_back(p[i]);
      while (k % p[i] == 0) k /= p[i];
    }
    if (k != 1) factor[id].push_back(k);
    for (long long v : factor[id])
      ;
    ;
    if (factor[id].size() > 2) {
      ;
      long long p = factor[id][0];
      minvalue[id].resize(p, INFF);
      minvalue[id][0] = 0;
      Q.push(make_pair(0ll, 0ll));
      while (Q.size()) {
        auto now = Q.top();
        Q.pop();
        long long pos = now.second;
        if (minvalue[id][pos] != now.first) continue;
        for (long long len : factor[id])
          if (len != p) {
            long long nxtpos = (pos + len) % p,
                      nxtlen = minvalue[id][pos] + len;
            if (minvalue[id][nxtpos] > nxtlen) {
              minvalue[id][nxtpos] = nxtlen;
              Q.push(make_pair(minvalue[id][nxtpos], nxtpos));
            }
          }
      }
    }
  }
  if (factor[id].size() == 0) {
    return 0 * puts("NO");
  }
  if (factor[id].size() == 1) {
    if (n % factor[id][0] == 0)
      return 0 * puts("YES");
    else
      return 0 * puts("NO");
  }
  if (factor[id].size() == 2) {
    long long inv, a, p1 = factor[id][0], p2 = factor[id][1];
    inv = powMM(p1, p2 - 2, p2);
    a = n % p2 * inv % p2;
    if (a * p1 <= n)
      return 0 * puts("YES");
    else
      return 0 * puts("NO");
  } else {
    if (minvalue[id][n % factor[id][0]] <= n)
      return 0 * puts("YES");
    else
      return 0 * puts("NO");
  }
}
int main() {
  int startTime = clock();
  initfactor();
  ;
  int T = 1;
  scanf("%d", &T);
  startTime = clock();
  while (T--) TaskA();
  ;
}