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;
pair<pair<long long int, long long int>, int> queries[10000];
bitset<32000000> bs;
vector<int> primes;
long long int dist[100000];
priority_queue<pair<long long int, int> > H;
int ans[10000];
int main() {
  int i;
  int t;
  long long int n, k;
  scanf("%d", &t);
  for (i = 0; i < t; i++)
    scanf("%I64d %I64d", &n, &k), queries[i] = make_pair(make_pair(k, n), i);
  sort(queries, queries + t);
  int j;
  bs.set();
  bs[0] = bs[1] = 0;
  for (i = 2; i < 32000000; i++) {
    if (bs[i]) {
      if (i < 6000) {
        for (j = i * i; j < 32000000; j += i) bs[j] = 0;
      }
      primes.push_back(i);
    }
  }
  vector<long long int> f;
  for (i = 0; i < t; i++) {
    k = queries[i].first.first, n = queries[i].first.second;
    if ((i == 0) || (k != queries[i - 1].first.first)) {
      int e = sqrt(k) + 1e-6;
      f.clear();
      for (j = 0; primes[j] <= e; j++) {
        if ((k % primes[j]) == 0) {
          f.push_back(primes[j]);
          while ((k % primes[j]) == 0) k /= primes[j];
        }
      }
      if (k > 1) f.push_back(k);
      if (f.size() > 2) {
        fill(dist, dist + f[0], -1);
        dist[0] = 0;
        H.push(make_pair(0, 0));
        while (!H.empty()) {
          int u = H.top().second;
          int d = -H.top().first;
          H.pop();
          if (d > dist[u]) continue;
          for (j = 1; j < f.size(); j++) {
            int v = (u + f[j]) % f[0];
            if ((dist[v] == -1) || (dist[u] + f[j] < dist[v])) {
              dist[v] = dist[u] + f[j];
              H.push(make_pair(-dist[v], v));
            }
          }
        }
      }
    }
    if (f.size() == 0)
      ans[queries[i].second] = 0;
    else if (f.size() == 1)
      ans[queries[i].second] = ((n % f[0]) == 0);
    else if (f.size() == 2) {
      int e = f[1] - 2;
      long long int b = f[0], r = n % f[1];
      while (e > 0) {
        if (e & 1) r *= b, r %= f[1];
        e >>= 1;
        b *= b, b %= f[1];
      }
      ans[queries[i].second] = (n >= r * f[0]);
    } else
      ans[queries[i].second] = (dist[n % f[0]] != -1) && (dist[n % f[0]] <= n);
  }
  for (i = 0; i < t; i++) printf(ans[i] ? "YES\n" : "NO\n");
  return 0;
}