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 MOD = 998244353;
long long mod_exp(long long x, long long y, long long mod) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return res;
}
long long choose2(long long k) { return (k * (k - 1) / 2) % MOD; }
long long contribute(vector<pair<int, int> >& multi) {
  int m = multi.size();
  long long card = 0;
  for (int i = 0; i < m; i++) {
    card += multi[i].second;
  }
  if (card <= 1) return 0;
  long long subsets2 = mod_exp(2, card - 2, MOD);
  long long subsets3;
  if (card >= 3) subsets3 = mod_exp(2, card - 3, MOD);
  long long ans = 0;
  long long prefix = 0;
  for (int i = 0; i < m; i++) {
    long long curr = multi[i].first;
    long long numpairs = choose2(multi[i].second);
    long long fixedcta = (2 * subsets2) % MOD;
    if (card >= 3) {
      long long inc = (2 * (card - 2)) % MOD;
      inc = (inc * subsets3) % MOD;
      fixedcta = (fixedcta + inc) % MOD;
    }
    long long inc = (numpairs * fixedcta) % MOD;
    inc = (inc * curr) % MOD;
    inc = (inc * curr) % MOD;
    ans = (ans + inc) % MOD;
    numpairs = multi[i].second;
    long long fixedct = (((card - 1) % MOD) * subsets2) % MOD;
    inc = (numpairs * fixedct) % MOD;
    inc = (inc * curr) % MOD;
    inc = (inc * curr) % MOD;
    ans = (ans + inc) % MOD;
    inc = (prefix * numpairs) % MOD;
    inc = (inc * curr) % MOD;
    inc = (inc * fixedcta) % MOD;
    ans = (ans + inc) % MOD;
    prefix = (prefix + 1ll * multi[i].first * multi[i].second) % MOD;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int fq[(int)1e5 + 69];
  int xtra[(int)1e5 + 69];
  memset(fq, 0, sizeof fq);
  memset(xtra, 0, sizeof xtra);
  int m;
  cin >> m;
  vector<pair<int, int> > multi(m);
  for (int i = 0; i < m; i++) {
    cin >> multi[i].first >> multi[i].second;
    fq[multi[i].first] = multi[i].second;
  }
  long long ans = contribute(multi);
  long long totOvercount = 0;
  for (int i = 1e5; i >= 2; i--) {
    long long sub = 0;
    vector<pair<int, int> > tmp;
    for (int j = i; j <= 1e5; j += i) {
      sub = (sub + xtra[j]) % MOD;
      if (fq[j] > 0) tmp.push_back(make_pair(j, fq[j]));
    }
    long long overcount = contribute(tmp);
    overcount = (overcount - sub) % MOD;
    overcount = (overcount + MOD) % MOD;
    xtra[i] = overcount;
    totOvercount = (totOvercount + overcount) % MOD;
  }
  ans = (ans - totOvercount) % MOD;
  ans = (ans + MOD) % MOD;
  cout << ans << '\n';
}
