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 long long MOD = 998244353;
const int N = 100000;
int n, m;
long long ans;
long long a[maxn], c[maxn];
int is[maxn], prime[maxn], cnt = 0;
long long mu[maxn];
long long f[maxn];
long long qsm(long long i, long long po) {
  long long res = 1ll;
  while (po) {
    if (po & 1) res = 1ll * res * i % M;
    po >>= 1;
    i = 1ll * i * i % M;
  }
  return res;
}
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;
}
vector<pair<int, int> > v;
int main() {
  m = read();
  long long x, y;
  for (int i = 1; i <= m; ++i) {
    x = read();
    c[x] += read();
  }
  long long inv = qsm(2, M - 2);
  is[1] = mu[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 s = 0;
    long long K = 0;
    for (int j = i; j <= N; j += i) {
      if (c[j]) {
        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);
        (f[i] += 1LL * (K - 1) % MOD * j.first % MOD * j.first % MOD * tt %
                 MOD * j.second % MOD) %= MOD;
      }
      if (cnt >= 3) (tt += 1LL * (K - 2) % MOD * tt % MOD * inv % MOD) %= MOD;
      (f[i] += 1LL * j.first * j.first % MOD * tt % MOD * j.second % MOD *
               (j.second - 1) % MOD);
      (f[i] += 1LL * j.first * j.second % MOD * tt % MOD *
               (s - 1LL * j.first * j.second % MOD) % MOD) %= MOD;
    }
  }
  for (int i = 1; i <= 100000; i++) (ans += 1LL * mu[i] * f[i] % MOD) %= MOD;
  printf("%lld\n", (ans % MOD + MOD) % MOD);
  return 0;
}