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 mod_pow(long long a, long long b, long long mod) {
  long long res = 1, c = a;
  while (b) {
    if (b & 1) res = res * c % mod;
    c = c * c % mod;
    b /= 2;
  }
  return res;
}
long long sol(vector<long long> &a) {
  int n = (int)a.size();
  long long mod = 998244353;
  long long sum = 0;
  long long sum2 = 0;
  long long sum3 = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    sum2 += a[i] * i;
    sum3 += a[i];
    sum %= (mod - 1);
    sum2 %= mod;
    sum3 %= mod;
  }
  long long res = 0;
  long long c1 = mod_pow(2, sum + (mod - 1) - 2, mod);
  for (int i = 0; i < n; i++) {
    res = (res + a[i] * i % mod * i % mod * c1 % mod * (sum3 + mod - 1) % mod) %
          mod;
  }
  sum2 = sum2 * sum2 % mod;
  for (int i = 0; i < n; i++) {
    sum2 = (sum2 + mod - a[i] * i % mod * i % mod) % mod;
  }
  res = (res + sum2 * mod_pow(2, sum - 3 + (mod - 1), mod) % mod * sum3 % mod) %
        mod;
  return res;
}
vector<int> minimum_prime_fuctors(int x) {
  vector<int> res(x + 1);
  vector<int> primes;
  for (int i = 2; i <= x; i++) {
    if (res[i] == 0) {
      res[i] = i;
      primes.push_back(i);
    }
    for (int j = 0;
         j < primes.size() && primes[j] <= res[i] && primes[j] * i <= x; j++) {
      res[i * primes[j]] = primes[j];
    }
  }
  return res;
}
vector<int> mobius_function(int x) {
  vector<int> res(x + 1);
  vector<int> mp = minimum_prime_fuctors(x);
  res[1] = 1;
  for (int i = 2; i <= x; i++) {
    if (mp[i] == mp[i / mp[i]])
      res[i] = 0;
    else
      res[i] = -res[i / mp[i]];
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int mx = 101010;
  vector<long long> a(mx);
  for (int i = 0; i < n; i++) {
    int v;
    long long x;
    cin >> v >> x;
    a[v] = x;
  }
  vector<int> moe = mobius_function(mx);
  long long res = 0;
  long long mod = 998244353;
  for (int i = 1; i < mx; i++) {
    vector<long long> s(1, 0);
    for (int j = i; j < mx; j += i) {
      s.push_back(a[j]);
    }
    res = (res + mod + sol(s) * i % mod * i % mod * moe[i] % mod) % mod;
  }
  cout << res << "\n";
  return 0;
}
