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;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
const long long maxn = 1e5 + 10, N = 2e6 + 10, SQ = 600, base = 1999,
                mod = 998244353, INF = 1e18, lg = 30;
long long m, dp[maxn], a[maxn];
inline long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    a[x] = y;
  }
  for (long long i = maxn - 1; i > 0; --i) {
    long long k = 0, x = 0, y = 0;
    for (long long j = i; j < maxn; j += i) {
      k += a[j];
      (x += a[j] * j) %= mod;
      (y += a[j] * j % mod * j) %= mod;
      (dp[i] += mod - dp[j]) %= mod;
    }
    if (k <= 1) continue;
    long long p = power(2, (mod + k - 4) % (mod - 1));
    k %= mod;
    (dp[i] += 2 * p * (mod + k - 1) % mod * y) %= mod;
    (dp[i] += p * k % mod * (mod + x * x % mod - y)) %= mod;
  }
  cout << dp[1] << '\n';
}