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;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll OO = 100000000000000000LL;
ll md = 998244353;
ll *fac, *ifac;
ll ad(ll a, ll b, ll mod = md) { return (a % mod + b % mod + mod) % mod; }
ll ml(ll a, ll b, ll mod = md) { return ((a % mod) * (b % mod)) % mod; }
ll pw(ll a, ll n, ll mod = md) {
  ll res = 1;
  a %= md;
  while (n) {
    if (n & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    n >>= 1;
  }
  return res;
}
void cachefact(int lim, const ll mod = md) {
  fac = new ll[lim + 1], ifac = new ll[lim + 1];
  fac[0] = ifac[0] = ifac[1] = fac[1] = 1;
  for (int i = 2; i <= lim; i++) {
    ifac[i] = (ifac[mod % i] * (mod - mod / i)) % mod;
  }
  for (ll i = 2; i <= lim; i++) {
    fac[i] = (fac[i - 1] * i) % mod;
    ifac[i] = (ifac[i - 1] * (ll)ifac[i]) % mod;
  }
}
ll C(int n, int r) {
  if (r == n) return 1;
  if (n < r || r < 0) return 0;
  return ml(fac[n], ml(ifac[r], ifac[n - r]));
}
const int N = 1e5;
ll f[N + 1] = {0};
int dp[N + 1] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m;
  cin >> m;
  for (int i = 0, x, y; i < m; ++i) {
    cin >> x >> y;
    f[x] = y;
  }
  ll total, weights, aux;
  int j;
  for (int i = N; i; --i) {
    total = 0;
    weights = 0;
    aux = 0;
    for (j = i; j <= N; j += i) {
      total += f[j];
      weights = ad(weights, ml(f[j], j));
      aux = ad(aux, ml(j, ml(j, f[j])));
    }
    if (total >= 2) {
      dp[i] = ml(aux, ml(total - 1, pw(2, total - 2)));
      aux = (0 - aux + md) % md;
      for (j = i; j <= N; j += i) {
        aux = ad(aux, ml(weights, ml(j, f[j])));
      }
      dp[i] =
          ad(dp[i], ml(pw(2, total - 2) +
                           (total > 2 ? ml(total - 2, pw(2, total - 3)) : 0),
                       aux));
    }
    for (int j = 2 * i; j <= N; j += i) dp[i] = ad(dp[i], -dp[j]);
  }
  cout << dp[1] << "\n";
  return 0;
}
