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;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 102000;
const long long inf = 3e18;
int prime[4000000], len;
long long dis[N];
map<long long, int> Map;
int num;
long long rec[75][N];
bool isprime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
void getp(int n) {
  static int small[10000];
  static bool vis[10000];
  int sz = 0, S = sqrt(n) + 0.5;
  for (register int i = (2); i <= (S); i++)
    if (isprime(i)) small[++sz] = i, prime[++len] = i;
  for (int l = S + 1; l <= n; l += S) {
    memset(vis, 0, sizeof(vis));
    int r = min(n, l + S - 1);
    for (register int i = (1); i <= (sz); i++)
      for (register int j = r / small[i] * small[i]; j >= l; j -= small[i])
        vis[j - l] = 1;
    for (register int i = (0); i <= (S - 1); i++)
      if (!vis[i]) prime[++len] = l + i;
  }
}
inline vector<long long> getfac(long long n) {
  static map<long long, vector<long long> > Map;
  long long rec = n;
  if (Map.count(n)) return Map[n];
  vector<long long> res;
  for (register int i = 1; i <= len && 1LL * prime[i] * prime[i] <= n; i++)
    if (n % prime[i] == 0) {
      res.push_back(prime[i]);
      while (n % prime[i] == 0) n /= prime[i];
    }
  if (n > 1) res.push_back(n);
  return Map[rec] = res;
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
inline 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;
}
inline long long mul(long long a, long long b, long long mo) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a) % mo;
    a = (a + a) % mo;
    b >>= 1;
  }
  return res;
}
inline bool ckeq(long long c, long long a, long long b) {
  long long g = gcd(a, b);
  if (c % g) return 0;
  a /= g;
  b /= g;
  c /= g;
  long long x, y;
  exgcd(a, b, x, y);
  x = mul(x, c, b);
  x = (x + b) % b;
  return c - a * x >= 0;
}
int main() {
  getp(35000000);
  int T;
  read(T);
  while (T--) {
    long long nn, k;
    scanf("%lld%lld", &nn, &k);
    vector<long long> s = getfac(k);
    if (k == 1)
      puts("NO");
    else if (((int)s.size()) == 1)
      printf("%s\n", nn % s[0] == 0 ? "YES" : "NO");
    else if (((int)s.size()) == 2)
      printf("%s\n", ckeq(nn, s[0], s[1]) ? "YES" : "NO");
    else {
      if (!Map.count(k)) {
        priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                       greater<pair<long long, int> > >
            heap;
        int n = s[0];
        for (register int i = (0); i <= (n - 1); i++) dis[i] = inf;
        dis[0] = 0;
        heap.push(pair<long long, int>(dis[0], 0));
        while (!heap.empty()) {
          int u = heap.top().second;
          if (heap.top().first != dis[u]) {
            heap.pop();
            continue;
          }
          heap.pop();
          for (register int i = (1); i <= (((int)s.size()) - 1); i++) {
            int v = (u + s[i]) % n;
            long long d = dis[u] + s[i];
            if (d < dis[v]) {
              dis[v] = d;
              heap.push(pair<long long, int>(d, v));
            }
          }
        }
        Map[k] = ++num;
        for (register int i = (0); i <= (s[0] - 1); i++) rec[num][i] = dis[i];
      }
      assert(num <= 50);
      printf("%s\n", rec[Map[k]][nn % s[0]] <= nn ? "YES" : "NO");
    }
  }
  return 0;
}