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;
long long n, ans[200005], sums[200005], sump[200005], sumq[200005];
long long ra[200005], mod = 998244353;
long long add(long long x, long long y) {
  x += y;
  x %= mod;
  if (x < 0) x += mod;
  return x;
}
long long pw(long long x, long long y) {
  if (y < 0) return 0;
  long long ret = 1;
  while (y) {
    if (y & 1) ret = (ret * x) % mod;
    x = x * x % mod;
    y /= 2;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long x, y;
    cin >> x >> y;
    long long second = x * y % mod;
    long long sq = x * x % mod * y % mod;
    long long sp = x * x % mod * y % mod * (y - 1) % mod;
    for (int j = 1; j <= sqrt(x); j++) {
      if (x % j) continue;
      long long k = j;
      ra[k] += y;
      sump[k] = (sump[k] + sp + 2 * sums[k] * second % mod) % mod;
      sums[k] = (sums[k] + second) % mod;
      sumq[k] = (sumq[k] + sq) % mod;
      if (x / j == j) continue;
      k = x / j;
      ra[k] += y;
      sump[k] = (sump[k] + sp + 2 * sums[k] * second % mod) % mod;
      sums[k] = (sums[k] + second) % mod;
      sumq[k] = (sumq[k] + sq) % mod;
    }
  }
  for (int i = 100000; i >= 1; i--) {
    long long k = ra[i];
    if (k == 0) continue;
    ans[i] = sumq[i] * pw(2, k - 2) % mod * ((k - 1) % mod) % mod;
    ans[i] = add(
        ans[i],
        sump[i] * (pw(2, k - 3) * ((k - 2) % mod) % mod + pw(2, k - 2)) % mod);
    for (int j = 2 * i; j <= 100000; j += i) ans[i] = add(ans[i], -ans[j]);
  }
  cout << ans[1] << '\n';
  return 0;
}
