Problem: You are given a positive integer D. Let's build the following graph from it: 

  * each vertex is a divisor of D (not necessarily prime, 1 and D itself are also included); 
  * two vertices x and y (x > y) have an undirected edge between them if x is divisible by y and \frac x y is a prime; 
  * the weight of an edge is the number of divisors of x that are not divisors of y. 



For example, here is the graph for D=12: 

<image>

Edge (4,12) has weight 3 because 12 has divisors [1,2,3,4,6,12] and 4 has divisors [1,2,4]. Thus, there are 3 divisors of 12 that are not divisors of 4 — [3,6,12].

There is no edge between 3 and 2 because 3 is not divisible by 2. There is no edge between 12 and 3 because 12/3=4 is not a prime.

Let the length of the path between some vertices v and u in the graph be the total weight of edges on it. For example, path [(1, 2), (2, 6), (6, 12), (12, 4), (4, 2), (2, 6)] has length 1+2+2+3+1+2=11. The empty path has length 0.

So the shortest path between two vertices v and u is the path that has the minimal possible length.

Two paths a and b are different if there is either a different number of edges in them or there is a position i such that a_i and b_i are different edges.

You are given q queries of the following form: 

  * v u — calculate the number of the shortest paths between vertices v and u. 



The answer for each query might be large so print it modulo 998244353.

Input

The first line contains a single integer D (1 ≤ D ≤ 10^{15}) — the number the graph is built from.

The second line contains a single integer q (1 ≤ q ≤ 3 ⋅ 10^5) — the number of queries.

Each of the next q lines contains two integers v and u (1 ≤ v, u ≤ D). It is guaranteed that D is divisible by both v and u (both v and u are divisors of D).

Output

Print q integers — for each query output the number of the shortest paths between the two given vertices modulo 998244353.

Examples

Input


12
3
4 4
12 1
3 4


Output


1
3
1


Input


1
1
1 1


Output


1


Input


288807105787200
4
46 482955026400
12556830686400 897
414 12556830686400
4443186242880 325


Output


547558588
277147129
457421435
702277623

Note

In the first example: 

  * The first query is only the empty path — length 0; 
  * The second query are paths [(12, 4), (4, 2), (2, 1)] (length 3+1+1=5), [(12, 6), (6, 2), (2, 1)] (length 2+2+1=5) and [(12, 6), (6, 3), (3, 1)] (length 2+2+1=5). 
  * The third query is only the path [(3, 1), (1, 2), (2, 4)] (length 1+1+1=3). 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 220, mod = 998244353;
long long D, q;
int fac[MAX_N], inv[MAX_N], fac_inv[MAX_N];
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int base[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
long long multiply(long long x, long long y, long long cmod) {
  long long tmp =
      (x * y - (long long)((long double)x / cmod * y + 1.0e-8) * cmod) % cmod;
  return tmp < 0 ? tmp + cmod : tmp;
}
long long fpow(long long bas, long long tim, long long cmod) {
  long long ret = 1;
  while (tim) {
    if (tim & 1) ret = multiply(ret, bas, cmod);
    bas = multiply(bas, bas, cmod);
    tim >>= 1;
  }
  return ret;
}
bool millerRabin(long long curt) {
  for (auto cbase : base) {
    if (cbase == curt)
      return true;
    else if (cbase > curt)
      return false;
    long long x = fpow(cbase, curt - 1, curt), idx = curt - 1;
    if (x != 1) return false;
    while (x == 1 && idx % 2 == 0) {
      idx /= 2, x = fpow(cbase, idx, curt);
      if (x != 1 && x != curt - 1) return false;
    }
  }
  return true;
}
long long pollardRho(long long n) {
  if (n % 2 == 0) return 2;
  if (n % 3 == 0) return 3;
  long long x = 0, y = 0, c = rand() % (n - 1) + 1, bas = 1, unit = (1 << 7),
            factor = 1;
  for (long long step = 2;; step <<= 1, y = x, bas = 1) {
    for (long long i = 1; i <= step; i++) {
      x = (multiply(x, x, n) + c) % n;
      bas = multiply(bas, abs(x - y), n);
      if (i % unit == 0) {
        factor = gcd(bas, n);
        if (factor > 1) return factor;
      }
    }
    if (factor > 1 || ((factor = gcd(bas, n)) > 1)) return factor;
  }
  return n;
}
vector<long long> p;
void factorize(long long x) {
  if (x == 1) return;
  if (millerRabin(x)) return (void)(p.push_back(x));
  long long p = x;
  while (p == x) p = pollardRho(x);
  while (x % p == 0) x /= p;
  factorize(p), factorize(x);
}
int main() {
  for (int i = fac[0] = 1; i < 200; i++) fac[i] = 1LL * fac[i - 1] * i % mod;
  inv[0] = inv[1] = 1, fac_inv[0] = fac_inv[1] = 1;
  for (int i = 2; i < 200; i++)
    inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod,
    fac_inv[i] = 1LL * fac_inv[i - 1] * inv[i] % mod;
  scanf("%lld%lld", &D, &q);
  for (long long i = 2; 1LL * i * i <= D; i++) {
    if (D % i == 0) p.push_back(i);
    while (D % i == 0) D /= i;
  }
  if (D > 1) p.push_back(D);
  while (q--) {
    long long u, v;
    scanf("%lld%lld", &u, &v);
    long long d = gcd(u, v);
    long long u_i = u / d, v_i = v / d;
    int ans_1 = 1, ans_2 = 1;
    long long tot = 0;
    for (long long x : p)
      if (x <= u_i) {
        long long pans = 0;
        while (u_i % x == 0) pans++, u_i /= x;
        tot += pans, ans_1 = 1LL * ans_1 * fac_inv[pans] % mod;
      } else
        break;
    ans_1 = 1LL * ans_1 * fac[tot] % mod;
    tot = 0;
    for (long long x : p)
      if (x <= v_i) {
        long long pans = 0;
        while (v_i % x == 0) pans++, v_i /= x;
        tot += pans, ans_2 = 1LL * ans_2 * fac_inv[pans] % mod;
      } else
        break;
    ans_2 = 1LL * ans_2 * fac[tot] % mod;
    int ans = 1LL * ans_1 * ans_2 % mod;
    printf("%d\n", ans);
  }
  return 0;
}