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;
const int MOD = 998244353;
void addmod(long long &x, long long d) {
  x += d;
  if (x >= MOD) {
    x -= MOD;
  }
  if (x < 0) {
    x += MOD;
  }
}
long long powmod(long long a, long long b) {
  long long ret = 1;
  long long p = a;
  while (b) {
    if (b & 1) {
      ret = ret * p % MOD;
    }
    p = p * p % MOD;
    b >>= 1;
  }
  return ret;
}
vector<long long> sum;
vector<long long> sum1;
vector<long long> sum2;
vector<long long> cnt;
void add(int i, long long s, long long s1, long long s2, long long f) {
  addmod(sum2[i], (s2 + 2 * s * sum[i]) % MOD);
  addmod(sum1[i], s1);
  addmod(sum[i], s);
  cnt[i] += f;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int m;
  cin >> m;
  const int n = 1e+5;
  sum.resize(n + 1, 0);
  sum1.resize(n + 1, 0);
  sum2.resize(n + 1, 0);
  cnt.resize(n + 1, 0);
  for (int i = 0; i < m; i++) {
    long long x, f;
    cin >> x >> f;
    long long s = x * f % MOD;
    long long s1 = x * x % MOD * f % MOD;
    long long s2 = x * x % MOD * ((f - 1) * f % MOD) % MOD;
    for (int j = 1; j * j <= x; ++j) {
      if (x % j) continue;
      add(j, s, s1, s2, f);
      if (x / j != j) {
        add(x / j, s, s1, s2, f);
      }
    }
  }
  vector<long long> ans(n + 1, 0);
  for (int i = n; i >= 1; --i) {
    if (!cnt[i]) continue;
    long long k = cnt[i];
    long long p3, p2;
    p3 = p2 = 0;
    if (k > 2) {
      p3 = powmod(2, k - 3);
      p2 = p3 * 2 % MOD;
    } else if (k > 1) {
      p2 = powmod(2, k - 2);
    }
    if (k > 1) {
      addmod(ans[i], p2 * ((k - 1) % MOD) % MOD * sum1[i] % MOD);
      addmod(ans[i], p2 % MOD * sum2[i] % MOD);
    }
    if (k > 2) {
      addmod(ans[i], p3 * ((k - 2) % MOD) % MOD * sum2[i] % MOD);
    }
    for (int j = i + i; j <= n; j += i) {
      addmod(ans[i], -ans[j]);
    }
  }
  cout << ans[1] << endl;
  return 0;
}