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;
long long mod = 998244353;
int mdp[100010];
void crive() {
  for (int i = 2; i <= 100000; i++) {
    if (mdp[i] == 0) {
      mdp[i] = i;
      for (int j = 2 * i; j <= 100000; j += i) {
        if (mdp[j] == 0) mdp[j] = i;
      }
    }
  }
}
long long ss[100010], sq[100010], sf[100010], sf2[100010];
vector<int> div(long long a) {
  vector<int> ans;
  ans.push_back(1);
  long long u = a;
  while (u != 1) {
    int p = mdp[u], ps = mdp[u];
    int k = 0;
    while (u % p == 0) {
      k++;
      u /= p;
    }
    int sz = ans.size();
    for (int j = 1; j <= k; j++) {
      for (int i = 0; i < sz; i++) {
        ans.push_back(p * ans[i]);
      }
      p *= ps;
    }
  }
  sort(ans.begin(), ans.end());
  return ans;
}
long long resp[100010];
long long pt2(int a) {
  if (a == 0) return 1;
  if (a < 0) return 0;
  long long ans = pt2(a / 2);
  ans = (ans * ans) % mod;
  ;
  if (a & 1) ans = (ans * 2) % mod;
  return ans;
}
long long mt(long long a, long long b) { return (a * b) % mod; }
int main() {
  crive();
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    long long a, f;
    cin >> a >> f;
    vector<int> d = div(a);
    for (auto x : d) {
      ss[x] = (ss[x] + f * a) % mod;
      sq[x] = (sq[x] + mt(f, mt(a, a))) % mod;
      sf[x] = (sf[x] + f) % mod;
      sf2[x] = (sf2[x] + f) % (mod - 1);
    }
  }
  for (int i = 100000; i >= 1; i--) {
    long long t = sf[i], t2 = sf2[i];
    if (t == 1 && t2 == 1)
      resp[i] = 0;
    else {
      t += mod;
      t2 += mod - 1;
      resp[i] = ((mt(mt(t - 1, pt2(t2 - 2)), sq[i])) +
                 ((mt(t - 2, pt2(t2 - 3)) + pt2(t2 - 2)) *
                  (mt(ss[i], ss[i]) - sq[i])) %
                     mod) %
                mod;
    }
    for (int j = i * 2; j <= 100000; j += i) {
      resp[i] = (resp[i] - resp[j]) % mod;
    }
  }
  if (resp[1] < 0) resp[1] += mod;
  cout << resp[1] << endl;
}