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;
long long m;
vector<long long> a, c, res;
vector<vector<long long> > z;
void add(long long& x, long long y) { x = (x + y) % mod; }
long long mul(long long x, long long y, long long z = 1) {
  x = (x * y) % mod;
  x = (x * z) % mod;
  return x;
}
long long co(long long n) {
  long long res = n * (n - 1) / 2;
  return res % mod;
}
long long po(long long x, long long p) {
  long long res = 1;
  for (; p; p /= 2) {
    if (p % 2) res = (res * x) % mod;
    x = (x * x) % mod;
  }
  return res;
}
long long g(long long d) {
  long long num = 0;
  long long sum = 0;
  long long sii = 0;
  long long sij = 0;
  for (auto i : z[d]) {
    add(sii, mul(a[i], a[i], c[i]));
    add(sij, mul(a[i], c[i], sum) + mul(co(c[i]), a[i], a[i]));
    add(sum, mul(a[i], c[i]));
    num += c[i];
  }
  if (num < 2) return 0;
  long long res = mul((num - 1) % mod, sii) + mul(num % mod, sij);
  return po(2, num - 2) * res % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> m;
  a.resize(m);
  c.resize(m);
  z.resize(100001);
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> c[i];
    for (int x = 1; x * x <= a[i]; ++x) {
      if (a[i] % x) continue;
      z[a[i] / x].push_back(i);
      if (x * x != a[i]) z[x].push_back(i);
    }
  }
  res.assign(100001, 0);
  for (long long i = 100000; i > 0; --i) {
    res[i] = g(i);
    for (long long j = 2 * i; j <= 100000; j += i)
      res[i] = (res[i] + mod - res[j]) % mod;
  }
  cout << res[1] << endl;
  return 0;
}