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 std::map;
using std::priority_queue;
const int KV2 = 56, S = 32000000;
map<long long, int> mi;
int mar;
long long pr[2333333], pi;
bool vis[S + 1];
void sieve() {
  for (long long i = 2; i <= S; i++) {
    if (!vis[i]) pr[++pi] = i;
    for (int j = 1; j <= pi && pr[j] * i <= S; j++) {
      vis[pr[j] * i] = 1;
      if (i % pr[j] == 0) break;
    }
  }
}
struct sumireko {
  int to, ne;
  long long w;
} e[4000069];
int he[100069], ecnt;
void addline(int f, long long lt, long long w) {
  int t = lt;
  e[++ecnt].to = t;
  e[ecnt].ne = he[f];
  e[ecnt].w = w;
  he[f] = ecnt;
}
struct shion {
  int x;
  long long d;
  shion() {}
  shion(int x, long long d) : x(x), d(d) {}
  bool operator<(const shion &b) const { return d > b.d; }
} g;
long long dis[KV2][100069];
priority_queue<shion> q;
bool vv[100069];
void dijkstra(int ki) {
  memset(dis[ki], 0x7f, sizeof(dis[ki]));
  dis[ki][0] = 0;
  q.push(shion(0, 0));
  while (!q.empty()) {
    g = q.top(), q.pop();
    int px = g.x;
    long long pd = g.d;
    if (vv[px]) continue;
    vv[px] = 1;
    for (int i = he[px], t = e[i].to; i; i = e[i].ne, t = e[i].to) {
      if (pd + e[i].w < dis[ki][t]) {
        dis[ki][t] = pd + e[i].w;
        q.push(shion(t, dis[ki][t]));
      }
    }
  }
}
long long pl[KV2][68], pc[KV2];
void div(long long k, int ki) {
  int ti = 0;
  for (int i = 1; i <= pi && pr[i] * pr[i] <= k; i++) {
    if (k % pr[i] == 0) pl[ki][++ti] = pr[i];
    while (k % pr[i] == 0) k /= pr[i];
  }
  if (k != 1ll) pl[ki][++ti] = k;
  if (ti >= 3) {
    long long p1 = pl[ki][1];
    memset(he, 0, sizeof(he)), ecnt = 0;
    memset(vv, 0, sizeof(vv));
    for (int x = 0; x < p1; x++)
      for (int j = 2; j <= ti; j++) addline(x, (pl[ki][j] + x) % p1, pl[ki][j]);
    dijkstra(ki);
  }
  pc[ki] = ti;
}
long long fpow(long long a, long long p, long long mo) {
  a %= mo;
  long long ret = 1;
  while (p) {
    if (p & 1ll) ret = ret * a % mo;
    a = a * a % mo;
    p >>= 1;
  }
  return ret;
}
long long n, k;
int T;
int main() {
  sieve();
  scanf("%d", &T);
  while (T--) {
    scanf("%I64d%I64d", &n, &k);
    if (k == 1) {
      puts("NO");
      continue;
    }
    if (mi.find(k) == mi.end()) {
      mi[k] = ++mar;
      div(k, mar);
    }
    int ki = mi[k];
    switch (pc[ki]) {
      case 1: {
        puts(n % pl[ki][1] ? "NO" : "YES");
        break;
      }
      case 2: {
        long long p1 = pl[ki][1], p2 = pl[ki][2];
        puts(fpow(p2, p1 - 2, p1) * (n % p1) % p1 * p2 <= n ? "YES" : "NO");
        break;
      }
      default: {
        n < pl[ki][1]
            ? (puts("NO"))
            : (dis[ki][n % pl[ki][1]] <= n ? puts("YES") : puts("NO"));
        break;
      }
    }
  }
  return 0;
}