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 MOD = 998244353;
const long long N = 1e5 + 5;
long long m = 1e5, n;
long long cnt[N], ans;
long long p[N], mu[N];
bool np[N];
inline long long qpow(long long a, long long x) {
  long long res = 1;
  if (x < 0) return 0;
  for (; x; x >>= 1) (x & 1) && (res = res * a % MOD), a = a * a % MOD;
  return res;
}
long long bs[N], gs[N];
inline void prepare_pow() {
  bs[0] = gs[0] = 1;
  for (long long i = 1; i <= m; ++i) bs[i] = (bs[i - 1] << 1) % MOD;
  gs[1] = bs[m];
  for (long long i = 1; i <= m; ++i) gs[i] = gs[i - 1] * gs[1] % MOD;
}
inline long long spow(long long x) { return gs[x / m] * bs[x % m] % MOD; }
inline void prepare() {
  np[1] = 1;
  mu[1] = 1;
  for (long long i = 2, ni; i <= m; ++i) {
    if (!np[i]) {
      p[++p[0]] = i;
      mu[i] = -1;
    }
    for (long long j = 1; j <= p[0] && (ni = i * p[j]) <= m; ++j) {
      np[ni] = 1;
      if (i % p[j] == 0) break;
      mu[ni] = -mu[i];
    }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin >> n;
  prepare();
  prepare_pow();
  for (long long i = 1, x, v; i <= n; ++i) cin >> x >> v, cnt[x] += v;
  for (long long d = 1; d <= m; ++d) {
    if (!mu[d]) continue;
    long long A = -1, AS2 = 0, AS = 0, S = 0, S2 = 0, res = 1;
    long long nA = -1, nAS2 = 0, nAS = 0, nS = 0, nS2 = 0, nres = 1;
    for (long long i = d; i <= m; i += d) {
      if (cnt[i] == 0) continue;
      long long tmp = spow(cnt[i]), c1 = (cnt[i] * spow(cnt[i] - 1) % MOD),
                c2 = ((cnt[i] * (cnt[i] - 1) % MOD * spow(cnt[i] - 2) % MOD) +
                      (cnt[i] * spow(cnt[i] - 1) % MOD)) %
                     MOD,
                c3 = ((cnt[i] * (cnt[i] - 1) % MOD * (cnt[i] - 2) % MOD *
                       spow(cnt[i] - 3) % MOD) +
                      (cnt[i] * (cnt[i] - 1) % MOD * spow(cnt[i] - 2) % MOD) *
                          3 +
                      (cnt[i] * spow(cnt[i] - 1) % MOD)) %
                     MOD;
      nres = res * tmp % MOD;
      nS = (S * tmp % MOD + c1 * i % MOD * res % MOD) % MOD;
      nS2 = (S2 * tmp % MOD + 2 * i % MOD * S % MOD * c1 % MOD +
             i * i % MOD * c2 % MOD * res % MOD) %
            MOD;
      nA = (A * tmp % MOD + res * c1 % MOD) % MOD;
      nAS = (AS * tmp % MOD + i * A % MOD * c1 % MOD + S * c1 % MOD +
             i * c2 % MOD * res % MOD) %
            MOD;
      nAS2 = (AS2 * tmp % MOD + 2 * i % MOD * AS % MOD * c1 % MOD +
              A * i % MOD * i % MOD * c2 % MOD + S2 * c1 % MOD +
              2 * i % MOD * S % MOD * c2 % MOD +
              i * i % MOD * c3 % MOD * res % MOD) %
             MOD;
      A = nA;
      AS2 = nAS2;
      AS = nAS;
      S = nS;
      S2 = nS2;
      res = nres;
    }
    (ans += mu[d] * AS2 % MOD) %= MOD;
  }
  cout << (ans + MOD) % MOD << endl;
  return 0;
}