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;
namespace SHENZHEBEI {
static const int GYN = 2333333;
char SZB[GYN], *SS = SZB, *TT = SZB;
inline char gc() {
  if (SS == TT) {
    TT = (SS = SZB) + fread(SZB, 1, GYN, stdin);
    if (SS == TT) return '\n';
  }
  return *SS++;
}
inline long long read() {
  long long x = 0, g = 1;
  char ch = gc();
  for (; !isdigit(ch); ch = gc())
    if (ch == '-') g = -1;
  for (; isdigit(ch); ch = gc()) x = x * 10 - 48 + ch;
  return x * g;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline char readchar() {
  char ch = gc();
  for (; isspace(ch); ch = gc())
    ;
  return ch;
}
inline long long readstr(char *s) {
  char ch = gc();
  int cur = 0;
  for (; isspace(ch); ch = gc())
    ;
  for (; !isspace(ch); ch = gc()) s[cur++] = ch;
  s[cur] = '\0';
  return cur;
}
void Print(long long *a, int s, int t) {
  for (int i = (long long)(s); i <= (long long)(t); ++i) printf("%lld ", a[i]);
}
void Print(int *a, int s, int t) {
  for (int i = (long long)(s); i <= (long long)(t); ++i) printf("%d ", a[i]);
}
void Print(char *a, int s, int t) {
  for (int i = (long long)(s); i <= (long long)(t); ++i) putchar(a[i]);
}
void writeln(long long x) {
  write(x);
  puts("");
}
void Min(long long &x, long long y) { x = x < y ? x : y; }
void Max(long long &x, long long y) { x = x > y ? x : y; }
}  // namespace SHENZHEBEI
using namespace SHENZHEBEI;
const long long N = 500010;
struct dt {
  long long x, y, id;
} a[N];
bool mark[40000010];
long long TTT, q[1000], pri[8000010];
long long dis[200000], vis[200010], answ[200010];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    Q;
bool cmp(dt a, dt b) { return a.y < b.y; }
void Init() {
  TTT = 40000000;
  for (int i = (long long)(2); i <= (long long)(TTT); ++i)
    if (!mark[i]) {
      pri[++pri[0]] = i;
      for (long long j = 2 * i; j <= TTT; j += i) mark[j] = 1;
    }
}
void FenJie(long long x) {
  q[0] = 0;
  for (long long i = 1; pri[i] * pri[i] <= x; ++i)
    if (!(x % pri[i])) {
      q[++q[0]] = pri[i];
      for (; !(x % pri[i]); x /= pri[i])
        ;
    }
  if (x > 1) q[++q[0]] = x;
}
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}
long long mul(long long a, long long b, long long mod) {
  long long ans = 0;
  for (; b; b >>= 1, a = (a + a) % mod)
    if (b & 1) ans = (ans + a) % mod;
  return ans;
}
int main() {
  long long T = read();
  Init();
  for (int i = (long long)(1); i <= (long long)(T); ++i) {
    long long x = read(), y = read();
    a[i] = (dt){x, y, i};
  }
  sort(a + 1, a + T + 1, cmp);
  for (long long i = 1, j; i <= T; i = j + 1) {
    j = i;
    for (; a[j + 1].y == a[i].y;) ++j;
    FenJie(a[j].y);
    if (a[j].y == 1) q[q[0] = 1] = 1e18 + 10000;
    if (q[0] == 1) {
      for (int k = (long long)(i); k <= (long long)(j); ++k) {
        answ[a[k].id] = a[k].x % q[1] ? 0 : 1;
      }
    } else if (q[0] == 2) {
      long long A = q[1], B = q[2], X, Y, XX, YY;
      exgcd(A, B, X, Y);
      X = (X % B + B) % B;
      exgcd(B, A, XX, YY);
      XX = (XX % A + A) % A;
      for (int k = (long long)(i); k <= (long long)(j); ++k) {
        long long n = a[k].x, x = n % A, y = n % B,
                  ans = mul(x * XX, B, (A * B)) + mul(y * X, A, (A * B));
        answ[a[k].id] = n < ans ? 0 : 1;
      }
    } else {
      memset(vis, 0, sizeof vis);
      memset(dis, 60, sizeof dis);
      dis[0] = 0;
      Q.push(make_pair(0, 0));
      for (; !Q.empty();) {
        long long x = Q.top().second;
        Q.pop();
        if (vis[x]) continue;
        vis[x] = 1;
        for (int j = (long long)(2); j <= (long long)(q[0]); ++j) {
          long long dist = dis[x] + q[j], to = dist % q[1];
          if (dis[to] > dist) {
            dis[to] = dist;
            Q.push(make_pair(dis[to], to));
          }
        }
      }
      dis[0] = q[1];
      for (int k = (long long)(i); k <= (long long)(j); ++k)
        answ[a[k].id] = dis[a[k].x % q[1]] <= a[k].x ? 1 : 0;
    }
  }
  for (int i = (long long)(1); i <= (long long)(T); ++i)
    puts(answ[i] ? "YES" : "NO");
}