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 long long inf = 1e9;
const long long max_n = 1e5 + 3, mod = 998244353;
long long sum(long long a, long long b) {
  long long r = a + b;
  if (r >= mod) r -= mod;
  if (r < 0) r += mod;
  return (r % mod + mod) % mod;
}
long long mul(long long a, long long b) { return (a * b % mod + mod) % mod; }
long long mul(vector<long long> a) {
  long long r = 1;
  for (long long i : a) r = r % mod * i % mod;
  return (r + mod) % mod;
}
long long binpow(long long a, long long b) {
  if (b < 0) b += mod - 1;
  long long res = 1;
  for (; b; b /= 2, a = mul(a, a))
    if (b & 1) res = mul(res, a);
  return res;
}
void run() {
  long long n;
  cin >> n;
  vector<long long> f(max_n);
  for (long long i = 0; i < n; ++i) {
    long long v, x;
    cin >> v >> x;
    f[v] = x;
  }
  vector<long long> dp(max_n);
  for (long long k = 1e5; k >= 1; --k) {
    long long cnt = 0, sm = 0, sm2 = 0;
    bool lone = true;
    for (long long i = 0; i < max_n; i += k) {
      if (cnt != 0 && f[i] != 0) lone = false;
      cnt += f[i];
      sm = sum(sm, mul(f[i] % mod, i));
      sm2 = sum(sm2, mul({f[i] % mod, i, i}));
    }
    long long c = cnt % (mod - 1);
    cnt %= mod;
    if (!lone || cnt != 1) {
      dp[k] = sum(mul({sm % mod, sm % mod,
                       sum(mul(cnt - 2, binpow(2, c - 3)), binpow(2, c - 2))}),
                  mul({sm2, cnt - 2, binpow(2, c - 3)}));
    }
    for (long long i = 2 * k; i < max_n; i += k)
      dp[k] = sum(dp[k], mod - dp[i]);
  }
  cout << dp[1] % mod << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  run();
}