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 P = 998244353;
const long long N = 4e5 + 5;
long long fpow(long long x, long long k) {
  if (k < 0) return 0;
  long long ans = 1, base = x;
  while (k) {
    if (k & 1) ans = 1ll * ans * base % P;
    base = 1ll * base * base % P, k >>= 1;
  }
  return ans;
}
long long n, D, sum[N], cnt[N], s[N], a[N], w[N];
long long d[N], f[N], g[N], ans[N];
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld%lld", &a[i], &w[i]);
    long long u = a[i];
    d[u] = 1ll * a[i] * a[i] % P * w[i] % P;
    f[u] = a[i] * w[i] % P, g[u] = w[i];
    D = max(D, a[i]);
  }
  for (long long i = 1; i <= D; ++i) {
    for (long long j = i; j <= D; j += i)
      cnt[i] = (cnt[i] + g[j]), s[i] = (s[i] + d[j]) % P,
      sum[i] = (sum[i] + f[j]) % P;
  }
  for (long long i = 1; i <= D; ++i) {
    if (cnt[i] <= 1) continue;
    long long S = sum[i] * sum[i] % P;
    long long fS = s[i] % P;
    S = (S - fS + P) % P;
    long long ct = cnt[i];
    long long fg = (ct - 2) % P * fpow(2, ct - 3) % P;
    long long fu = fpow(2, ct - 2) % P;
    long long ff = (ct - 1) % P * fpow(2, ct - 2) % P;
    ans[i] = S * (fu + fg) % P;
    ans[i] = (ans[i] + fS * ff % P) % P;
  }
  for (long long i = D; i >= 1; --i) {
    for (long long j = i * 2; j <= D; j += i)
      ans[i] = (ans[i] - ans[j] + P) % P;
  }
  cout << (ans[1] % P + P) % P << endl;
  return 0;
}