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 N = 1e5;
const int mod = 998244353;
int m, a[N], f[N], dp[N];
vector<int> multiples[N];
int add(int x, int y) {
  if (x + y >= mod) {
    return x + y - mod;
  }
  return x + y;
}
int sub(int x, int y) {
  if (x - y < 0) {
    return x - y + mod;
  }
  return x - y;
}
int mul(int x, int y) { return (long long)x * y % mod; }
int exp(int x, long long y) {
  if (y < 0) {
    return 0;
  }
  y = y % (mod - 1);
  int ans = 1;
  while (y) {
    if (y & 1LL) {
      ans = mul(ans, x);
    }
    x = mul(x, x);
    y >>= 1LL;
  }
  return ans;
}
int inv(int x) { return exp(x, mod - 2); }
int fun(const vector<int> &s) {
  int xx = 0;
  int xy = 0;
  long long n = 0;
  for (int x : s) {
    xx = add(xx, mul(f[x], mul(x, x)));
    xy = add(xy, mul(f[x], x));
    n += (long long)f[x];
  }
  xy = sub(mul(xy, xy), xx);
  int en3 = exp(2, n - 3);
  int en2 = exp(2, n - 2);
  n = n % mod;
  int cxx = mul(en2, sub(n, 1));
  int cxy = add(mul(en3, sub(n, 2)), en2);
  return add(mul(xx, cxx), mul(xy, cxy));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> m;
  int ai, fr;
  for (int i = 1; i <= m; i++) {
    cin >> ai >> fr;
    f[ai] = fr;
    for (int d = 1; d * d <= ai; d++) {
      if (ai % d) continue;
      multiples[d].push_back(ai);
      if (ai / d != d) multiples[ai / d].push_back(ai);
    }
  }
  for (int d = N - 1; d > 0; d--) {
    if (multiples[d].empty()) continue;
    dp[d] = fun(multiples[d]);
    for (int x = d * 2; x < N; x += d) {
      dp[d] = sub(dp[d], dp[x]);
    }
  }
  cout << dp[1] << '\n';
  return 0;
}