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;
using ll = long long;
const int MOD = 998244353;
ll pow_two(ll n) {
  if (n == 0) {
    return 1;
  }
  if (n < 0) {
    n %= (MOD - 1);
    n += (MOD - 1);
  } else if (n >= MOD) {
    n %= (MOD - 1);
  }
  ll mid = pow_two(n >> 1);
  ll ans = mid * mid % MOD;
  if (n & 1) {
    ans <<= 1;
    ans %= MOD;
  }
  return ans;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int M;
  cin >> M;
  vector<ll> freqs;
  for (int i = 0; i < M; ++i) {
    int a;
    ll freq;
    cin >> a >> freq;
    if (a >= freqs.size()) {
      freqs.resize(a + 1);
    }
    freqs[a] += freq;
  }
  ll max_value = freqs.size() - 1;
  vector<ll> ans_divisible(max_value + 1);
  for (int i = 1; i <= max_value; ++i) {
    ll S1 = 0, S2 = 0, N = 0;
    for (ll j = i; j <= max_value; j += i) {
      S1 += j * freqs[j];
      S2 += (j * j % MOD) * freqs[j];
      N += freqs[j];
      S1 %= MOD;
      S2 %= MOD;
    }
    ll p1 = (S1 * S1 % MOD) * (N % MOD);
    p1 %= MOD;
    ll p2 = S2 * ((N - 2) % MOD);
    p2 %= MOD;
    ans_divisible[i] = ((p1 + p2) % MOD) * pow_two(N - 3);
    ans_divisible[i] %= MOD;
  }
  vector<int> sieve(max_value + 1, 1);
  for (int i = 2; i <= max_value; ++i) {
    if (sieve[i] == 1) {
      sieve[i] = i;
      for (int j = 2 * i; j <= max_value; j += i) {
        if (sieve[j] == 1) {
          sieve[j] = i;
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= max_value; ++i) {
    int prev_prime = 0, num_primes = 0;
    int copy = i;
    bool works = true;
    while (copy != 1) {
      if (prev_prime == sieve[copy]) {
        works = false;
        break;
      }
      prev_prime = sieve[copy];
      ++num_primes;
      copy /= sieve[copy];
    }
    if (works) {
      if (num_primes & 1) {
        ans += (MOD - ans_divisible[i]);
      } else {
        ans += ans_divisible[i];
      }
      ans %= MOD;
    }
  }
  cout << ans << "\n";
  return 0;
}