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.
#include <bits/stdc++.h>
using namespace std;
const long long M = 998244353;
long long rep(long long x) {
  x %= M;
  if (x < 0) {
    x += M;
  }
  return x;
}
long long add(long long a, long long b) {
  a = rep(a);
  b = rep(b);
  return rep(a + b);
}
long long mul(long long a, long long b) {
  a = rep(a);
  b = rep(b);
  return rep(a * b);
}
long long pw(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) {
      r = mul(r, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return r;
}
const long long N = (long long)1e5 + 7;
long long f[N];
long long dp[N];
long long get(long long tot) { return mul(tot, pw(2, tot - 1)); }
long long geta(long long tot) {
  if (tot < 2) {
    return 0;
  }
  return add(pw(2, tot - 2), get(tot - 2));
}
long long getb(long long tot) {
  if (tot < 1) {
    return 0;
  }
  return get(tot - 1);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long c;
  cin >> c;
  for (long long i = 1; i <= c; i++) {
    long long x, t;
    cin >> x >> t;
    f[x] = t;
  }
  for (long long x = N - 1; x >= 1; x--) {
    long long tot = 0;
    for (long long y = x; y < N; y += x) {
      tot += f[y];
    }
    long long a = geta(tot);
    long long b = getb(tot);
    vector<pair<long long, long long>> v;
    for (long long y = x; y < N; y += x) {
      if (f[y]) {
        v.push_back({y, f[y]});
      }
    }
    long long pre = 0;
    for (long long i = 0; i < (long long)v.size(); i++) {
      long long lol = pre;
      pre = add(pre, mul(v[i].second, v[i].first));
      lol = mul(lol, 2);
      lol = mul(lol, mul(v[i].first, v[i].second));
      lol = mul(lol, a);
      dp[x] = add(dp[x], lol);
      long long ct = v[i].second;
      dp[x] =
          add(dp[x], mul(mul(ct, ct - 1), mul(a, mul(v[i].first, v[i].first))));
      dp[x] = add(dp[x], mul(ct, mul(b, mul(v[i].first, v[i].first))));
    }
    for (long long y = 2 * x; y < N; y += x) {
      dp[x] = add(dp[x], -dp[y]);
    }
  }
  cout << dp[1] << "\n";
}
