Problem: You are given a multiset S. Over all pairs of subsets A and B, such that:

  * B ⊂ A; 
  * |B| = |A| - 1; 
  * greatest common divisor of all elements in A is equal to one; 



find the sum of ∑_{x ∈ A}{x} ⋅ ∑_{x ∈ B}{x}, modulo 998 244 353.

Input

The first line contains one integer m (1 ≤ m ≤ 10^5): the number of different values in the multiset S.

Each of the next m lines contains two integers a_i, freq_i (1 ≤ a_i ≤ 10^5, 1 ≤ freq_i ≤ 10^9). Element a_i appears in the multiset S freq_i times. All a_i are different.

Output

Print the required sum, modulo 998 244 353.

Examples

Input


2
1 1
2 1


Output


9


Input


4
1 1
2 1
3 1
6 1


Output


1207


Input


1
1 5


Output


560

Note

A multiset is a set where elements are allowed to coincide. |X| is the cardinality of a set X, the number of elements in it.

A ⊂ B: Set A is a subset of a set B.

In the first example B=\{1\}, A=\{1,2\} and B=\{2\}, A=\{1, 2\} have a product equal to 1⋅3 + 2⋅3=9. Other pairs of A and B don't satisfy the given constraints.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void cmin(T &a, T b) {
  ((a > b) && (a = b));
}
template <class T>
inline void cmax(T &a, T b) {
  ((a < b) && (a = b));
}
char IO;
template <class T = int>
T rd() {
  T s = 0;
  int f = 0;
  while (!isdigit(IO = getchar())) f |= IO == '-';
  do s = (s << 1) + (s << 3) + (IO ^ '0');
  while (isdigit(IO = getchar()));
  return f ? -s : s;
}
const int N = 1e5 + 10, P = 998244353;
int n, m;
long long qpow(long long x, long long k = P - 2) {
  long long res = 1;
  for (; k; k >>= 1, x = x * x % P)
    if (k & 1) res = res * x % P;
  return res;
}
const int D = 8;
int F[N][D];
int dp[4][D][D];
int B[D][D];
int C[10], Inv[10];
void Do(int x) {
  static unsigned long long G[D];
  memset(G, 0, sizeof G);
  for (int i = 0, iend = D - 1; i <= iend; ++i)
    for (int j = i, jend = D - 1; j <= jend; ++j)
      G[j] += 1ll * F[x][i] * B[i][j];
  for (int i = 0, iend = D - 1; i <= iend; ++i) F[x][i] = G[i] % P;
}
int Pow[3];
int main() {
  n = rd();
  for (int i = 1, iend = N - 1; i <= iend; ++i) F[i][0] = 1;
  Inv[0] = Inv[1] = 1;
  for (int i = 2, iend = 9; i <= iend; ++i)
    Inv[i] = 1ll * (P - P / i) * Inv[P % i] % P;
  for (int _ = 1, _end = n; _ <= _end; ++_) {
    int x = rd(), c = rd();
    for (int i = *Pow = 1, iend = 2; i <= iend; ++i)
      Pow[i] = 1ll * Pow[i - 1] * x % P;
    memset(dp, 0, sizeof dp);
    for (int i = 0, iend = D - 1; i <= iend; ++i) dp[0][i][i] = 1;
    for (int i = *C = 1, iend = 3; i <= iend; ++i)
      C[i] = 1ll * C[i - 1] * Inv[i] % P * (c - i + 1) % P;
    for (int d = 0, dend = 2; d <= dend; ++d) {
      for (int i = 0, iend = D - 1; i <= iend; ++i)
        for (int S = 1, Send = D - 2; S <= Send; ++S)
          if ((i & S) == 0 && ((S & 1) == 0 || (S & 4) == 0)) {
            for (int j = 0, jend = i; j <= jend; ++j)
              dp[d + 1][j][i | S] =
                  (dp[d + 1][j][i | S] +
                   1ll * Pow[(S & 1) + ((S & 2) > 0)] * dp[d][j][i]) %
                  P;
          }
    }
    memset(B, 0, sizeof B);
    for (int d = 0, dend = 3; d <= dend; ++d) {
      if (d > c) break;
      int val = 1ll * qpow(2, c - d) * C[d] % P;
      for (int i = 0, iend = D - 1; i <= iend; ++i)
        for (int j = i, jend = D - 1; j <= jend; ++j)
          B[i][j] = (B[i][j] + 1ll * val % P * dp[d][i][j]) % P;
    }
    for (int p = 1; p * p <= x; p++)
      if (x % p == 0) {
        Do(p);
        if (p * p != x) Do(x / p);
      }
  }
  for (int i = N - 1, iend = 1; i >= iend; --i)
    for (int j = i + i; j < N; j += i)
      F[i][7] -= F[j][7], ((F[i][7] < 0) && (F[i][7] += P));
  printf("%d\n", F[1][7]);
}