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;
int t, dis[100000];
vector<int> primes;
map<long long, vector<pair<long long, int>>> mp;
bool vis[100000], composite[32000000], res[10000];
vector<pair<int, int>> adj[100000];
void modifiedEuclid(long long f1, long long f2, long long &m1, long long &m2) {
  if (f1 == 0) {
    m1 = 0;
    m2 = 1;
    return;
  }
  modifiedEuclid(f2 % f1, f1, m2, m1);
  m1 -= m2 * (f2 / f1);
}
void calcPrimes() {
  for (int i = (2); i < (32000000); i++)
    if (!composite[i]) {
      for (int j = 2 * i; j < 32000000; j += i) composite[j] = 1;
      primes.push_back(i);
    }
}
vector<long long> factorize(long long k) {
  vector<long long> res;
  for (const int p : primes)
    if (k % p == 0) {
      res.push_back(p);
      while (k % p == 0) k /= p;
    }
  if (k > 1) res.push_back(k);
  return res;
}
void solve(const long long k, const vector<pair<long long, int>> &v) {
  vector<long long> factors = factorize(k);
  if (((int)(factors).size()) == 0)
    return;
  else if (((int)(factors).size()) == 1)
    for (const pair<long long, int> p : v)
      res[p.second] = p.first % factors[0] == 0;
  else if (((int)(factors).size()) == 2) {
    long long mult0, mult1;
    modifiedEuclid(factors[0], factors[1], mult0, mult1);
    mult1 = ((mult1 % factors[0]) + factors[0]) % factors[0];
    for (const pair<long long, int> p : v)
      res[p.second] =
          (mult1 * (p.first % factors[0]) % factors[0]) * factors[1] <= p.first;
  } else {
    for (int i = 0; i < (factors[0]); i++) adj[i].clear();
    for (int i = (1); i < (((int)(factors).size())); i++)
      for (int j = 0; j < (factors[0]); j++)
        adj[j].push_back(make_pair((j + factors[i]) % factors[0], factors[i]));
    memset(dis, 0, factors[0] * sizeof(int)),
        memset(vis, 0, factors[0] * sizeof(bool));
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        pq;
    pq.push(make_pair(0, 0));
    while (!pq.empty()) {
      pair<int, int> p = pq.top();
      pq.pop();
      if (vis[p.second]) continue;
      vis[p.second] = 1;
      dis[p.second] = p.first;
      for (const pair<int, int> next : adj[p.second])
        pq.push(make_pair(dis[p.second] + next.second, next.first));
    }
    for (const pair<long long, int> p : v)
      res[p.second] = p.first >= dis[p.first % factors[0]];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  calcPrimes();
  cin >> t;
  for (int i = 0; i < (t); i++) {
    long long n, k;
    cin >> n >> k;
    if (!mp.count(k)) mp.insert(make_pair(k, vector<pair<long long, int>>()));
    mp[k].push_back(make_pair(n, i));
  }
  for (auto p : mp) solve(p.first, p.second);
  for (int i = 0; i < (t); i++)
    if (res[i])
      cout << "YES\n";
    else
      cout << "NO\n";
}