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;
const int maxn = 100010;
const long long M = 998244353;
const int N = 100000;
int n, m;
long long ans;
long long a[maxn], c[maxn];
int is[maxn], prime[maxn], mu[maxn], cnt = 0;
long long qsm(long long i, long long po) {
  long long res = 1;
  while (po) {
    if (po & 1) res = 1ll * res * i % M;
    po >>= 1;
    i = 1ll * i * i % M;
  }
  return res;
}
vector<pair<int, int> > v;
long long read() {
  long long s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * f;
}
int main() {
  long long inv = qsm(2, M - 2);
  m = read();
  for (int i = 1; i <= m; ++i) {
    a[i] = read(), c[a[i]] = read();
  }
  mu[1] = 1, is[1] = 1;
  for (int i = 2; i <= N; ++i) {
    if (!is[i]) {
      prime[++cnt] = i;
      mu[i] = -1;
    }
    for (int j = 1; j <= cnt && i * prime[j] <= N; ++j) {
      is[i * prime[j]] = 1;
      if (i % prime[j] == 0) {
        mu[i * prime[j]] = 0;
        break;
      } else {
        mu[i * prime[j]] = -mu[i];
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    v.clear();
    long long s1 = 0, s2 = 0, s3 = 0, s = 0;
    long long K = 0;
    for (int j = i; j <= N; j += i) {
      if (!c[j]) continue;
      K += c[j];
      s = (s + 1ll * j * c[j] % M) % M;
      v.emplace_back(j, c[j]);
    }
    for (auto j : v) {
      long long tt = 0;
      if (K >= 2) {
        tt = qsm(2, K - 2);
        s1 = (s1 + 1ll * j.first * j.first % M * ((K - 1) % M) % M * tt % M *
                       j.second % M) %
             M;
      }
      if (K >= 3) {
        tt = (tt + 1LL * (K - 2) % M * tt % M * inv % M) % M;
      }
      s2 = (s2 + 1LL * j.first * j.first % M * tt % M * j.second % M *
                     (j.second - 1) % M) %
           M;
      s3 = (s3 + 1LL * j.first * j.second % M * tt % M *
                     (s - 1LL * j.first * j.second % M) % M) %
           M;
    }
    ans = ((ans + 1ll * mu[i] * ((s1 + s2 + s3) % M)) % M + M) % M;
  }
  printf("%lld\n", ans);
  return 0;
}