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 JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rustam Musin (t.me/musin_acm)
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    EPutiPoDelitelyam solver = new EPutiPoDelitelyam();
    solver.solve(1, in, out);
    out.close();
  }

  static class EPutiPoDelitelyam {
    int mod = 998244353;
    int[] fact;
    int[][] c;
    List<LongIntPair> F;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
      fact = new int[100];
      fact[0] = 1;
      for (int i = 1; i < fact.length; i++) fact[i] = mul(i, fact[i - 1]);
      c = new int[500][500];
      for (int n = 0; n < c.length; n++) {
        c[n][0] = 1;
        for (int k = 1; k <= n; k++) {
          c[n][k] = add(c[n - 1][k - 1], c[n - 1][k]);
        }
      }
      long d = in.readLong();
      F = factorize(d);
      int q = in.readInt();
      while (q-- > 0) {
        long a = in.readLong();
        long b = in.readLong();
        int res1 = paths(a, b);
        int res2 = paths(b, a);
        long res = mul(res1, res2);
        out.printLine(res);
      }
    }

    int mul(int a, int b) {
      long c = a * (long) b;
      return (int) (c % mod);
    }

    int add(int a, int b) {
      int c = a + b;
      if (c >= mod) c -= mod;
      return c;
    }

    int paths(long from, long to) {
      int res = 1;
      int totalDelta = 0;
      for (LongIntPair p : F) {
        int delta = getPower(to, p.first) - getPower(from, p.first);
        if (delta > 0) {
          res = mul(res, c[totalDelta += delta][delta]);
        }
      }
      return res;
    }

    List<LongIntPair> factorize(long x) {
      List<LongIntPair> fact = new ArrayList<>();
      for (long i = 2; i * i <= x; i++) {
        if (x % i == 0) {
          int p = 0;
          while (x % i == 0) {
            x /= i;
            p++;
          }
          fact.add(LongIntPair.makePair(i, p));
        }
      }
      if (x != 1) fact.add(LongIntPair.makePair(x, 1));
      return fact;
    }

    int getPower(long x, long p) {
      int r = 0;
      while (x % p == 0) {
        r++;
        x /= p;
      }
      return r;
    }

  }

  static class LongIntPair implements Comparable<LongIntPair> {
    public final long first;
    public final int second;

    public static LongIntPair makePair(long first, int second) {
      return new LongIntPair(first, second);
    }

    public LongIntPair(long first, int second) {
      this.first = first;
      this.second = second;
    }

    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }

      LongIntPair pair = (LongIntPair) o;

      return first == pair.first && second == pair.second;
    }

    public int hashCode() {
      int result = Long.hashCode(first);
      result = 31 * result + Integer.hashCode(second);
      return result;
    }

    public String toString() {
      return "(" + first + "," + second + ")";
    }

    public int compareTo(LongIntPair o) {
      int value = Long.compare(first, o.first);
      if (value != 0) {
        return value;
      }
      return Integer.compare(second, o.second);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public int readInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long readLong() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(long i) {
      writer.println(i);
    }

  }
}