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.
#include <bits/stdc++.h>
using namespace std;
long long n, ma = 1e5, fq[100069], dp[100069], pwk, dv = 998244353;
long long pw(long long x, long long y) {
  if (y < 0) {
    return 0;
  }
  if (!y) {
    return 1;
  }
  pwk = pw(x, y / 2);
  pwk = pwk * pwk % dv;
  if (y % 2) {
    pwk = pwk * x % dv;
  }
  return pwk;
}
int main() {
  long long i, j, k, l, c, sm, sm2, w;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld%lld", &k, &l);
    fq[k] += l;
  }
  for (i = ma; i; i--) {
    c = 0;
    sm = 0;
    sm2 = 0;
    w = 0;
    for (j = i; j <= ma; j += i) {
      c += fq[j];
      sm = (sm + j * j % dv * fq[j]) % dv;
      sm2 = (sm2 + j * fq[j] % dv * w * 2 +
             j * j % dv * fq[j] % dv * (fq[j] - 1)) %
            dv;
      w = (w + j * fq[j]) % dv;
      dp[i] = (dp[i] + dv - dp[j]);
    }
    dp[i] = (dp[i] + (c - 1) % dv * sm % dv * pw(2, c - 2) +
             sm2 * ((c - 2) % dv * pw(2, c - 3) % dv + pw(2, c - 2))) %
            dv;
  }
  printf("%lld\n", dp[1]);
}
