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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) { return l + rng() % (r - l + 1); }
const long long N = 1e5 + 5;
const long long mod = 998244353;
long long n, a[N];
long long e[N];
long long add(long long a, long long b) { return (a + b + mod) % mod; }
long long sub(long long a, long long b) { return ((a - b) % mod + mod) % mod; }
long long mul(long long a, long long b) { return a * b % mod; }
long long pw(long long x, long long i) {
  long long b = 1;
  for (; i; i >>= 1, x = x * x % mod)
    if (i & 1) b = mul(b, x);
  return b;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 1, _c = n; i <= _c; ++i) {
    long long x;
    cin >> x;
    cin >> a[x];
  }
  e[1] = 1;
  for (long long i = 1, _c = N - 5; i <= _c; ++i) {
    for (long long j = i * 2; j <= N - 5; j += i) e[j] -= e[i];
  }
  long long ans = 0;
  for (long long i = 1, _c = N - 5; i <= _c; ++i) {
    long long cnt = 0, tot = 0, ret = 0;
    for (long long j = i; j <= N - 5; j += i) {
      cnt += a[j];
      tot = (tot + a[j] % mod * j % mod) % mod;
      ret = (ret + a[j] % mod * j % mod * j % mod) % mod;
    }
    if (cnt < 2) continue;
    long long t1 = (ret * pw(2, cnt - 2) % mod) % mod * ((cnt - 1) % mod) % mod;
    long long p = (tot * tot % mod - ret + mod) % mod;
    long long q = pw(2, cnt - 2);
    if (cnt >= 3) q = (q + (cnt - 2) % mod * (pw(2, cnt - 3)) % mod) % mod;
    q = mul(q, p);
    ans = (ans + (q + t1) % mod * e[i] % mod) % mod;
    ans = (ans + mod) % mod;
  }
  cout << ans << '\n';
}