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;
inline long long read() {
  long long num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
const long long mod = 998244353;
inline long long qpow(long long x, long long k) {
  if (k < 0) return 0;
  long long res = 1;
  while (k) {
    if (k & 1) res = res * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return res;
}
long long n, a[100010], fre[100010], siz[100010], ans[100010], g[100010];
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read(), fre[a[i]] = read();
  }
  for (long long i = 1; i <= 100000; i++) {
    long long sum = 0, t1 = 0, t2 = 0;
    for (long long j = 1; i * j <= 100000; j++)
      siz[i] = siz[i] + fre[i * j],
      sum = (sum + fre[i * j] * i * j % mod) % mod;
    for (long long j = 1; i * j <= 100000; j++) {
      if (fre[i * j]) {
        t1 = (t1 + i * j * i * j % mod * fre[i * j] % mod) % mod;
        t2 = (t2 + fre[i * j] * i * j % mod * (sum - i * j + mod) % mod) % mod;
      }
    }
    ans[i] =
        (ans[i] + t1 * qpow(2, siz[i] - 2) % mod * ((siz[i] - 1) % mod) % mod) %
        mod;
    ans[i] = (ans[i] + t2 *
                           ((qpow(2, siz[i] - 3) * ((siz[i] - 2) % mod) % mod +
                             qpow(2, siz[i] - 2)) %
                            mod) %
                           mod) %
             mod;
  }
  for (long long i = 100000; i >= 1; i--)
    for (long long j = 2; i * j <= 100000; j++)
      ans[i] = (ans[i] - ans[i * j] + mod) % mod;
  printf("%lld\n", ans[1]);
  return 0;
}
