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;
inline long long add(long long a, long long b, long long mod) {
  return (a + b) % mod;
}
inline long long sub(long long a, long long b, long long mod) {
  return ((a - b) % mod + mod) % mod;
}
inline long long mul(long long a, long long b, long long mod) {
  return a * b % mod;
}
long long qpow(long long a, long long b, long long mod) {
  long long ret = 1;
  for (; b; b >>= 1) {
    if (b & 1) ret = mul(ret, a, mod);
    a = mul(a, a, mod);
  }
  return ret;
}
long long C2(long long x, long long mod) { return mul(x, sub(x, 1, mod), mod); }
const int N = 1e5 + 10;
const int maxn = 1e5;
long long mu[N]{0};
int v[N];
void init(int n, long long mod) {
  for (int i = 1; i <= n; i++) mu[i] = 1;
  memset(v, 0, sizeof(v));
  for (int i = 2; i <= n; i++) {
    if (v[i] == 0) {
      for (int j = i; j <= n; j += i) {
        if ((j / i) % i == 0)
          mu[j] = 0;
        else
          mu[j] = mu[j] * (-1);
        v[j] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) mu[i] = add(mu[i], mod, mod);
}
const long long mod = 998244353;
const long long mod1 = mod - 1;
long long a[N], freq[N];
int main() {
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%lld", a + i);
    scanf("%lld", freq + a[i]);
  }
  init(maxn, mod);
  long long ans = 0;
  for (int i = 1; i <= maxn; i++) {
    long long s = 0, ts = 0, sum = 0;
    for (int j = i; j <= maxn; j += i) s = s + freq[j];
    if (s < 2) continue;
    ts = s % mod1;
    s = s % mod;
    long long d1 = mul(sub(s, 1, mod), qpow(2, sub(ts, 2, mod1), mod), mod);
    long long d2 = add(mul(sub(s, 2, mod), qpow(2, sub(ts, 3, mod1), mod), mod),
                       qpow(2, sub(ts, 2, mod1), mod), mod);
    for (int j = i; j <= maxn; j += i) {
      sum = add(sum, mul(j, freq[j], mod), mod);
    }
    long long fi = 0;
    for (int j = i; j <= maxn; j += i) {
      long long t1 = mul(mul(mul(j, j, mod), freq[j], mod), d1, mod);
      long long t2 = mul(mul(mul(j, j, mod), C2(freq[j], mod), mod), d2, mod);
      long long t3 = mul(
          mul(mul(j, freq[j], mod), sub(sum, mul(j, freq[j], mod), mod), mod),
          d2, mod);
      fi = add(fi, add(t1, add(t2, t3, mod), mod), mod);
    }
    ans = add(ans, mul(mu[i], fi, mod), mod);
  }
  cout << ans << endl;
  return 0;
}