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>
const long long mod = 998244353;
long long num = 0;
long long f[100005], v[100005];
long long p[100005], mu[100005], freq[100005];
inline long long read() {
  register long long x = 0, f = 1;
  register char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
inline long long pow(long long x, long long p) {
  if (p < 0) return 0;
  long long res = 1;
  for (; p; p >>= 1) {
    if (p & 1) res = res * x % mod;
    x = x * x % mod;
  }
  return res;
}
inline long long calc(long long x, long long p) {
  return p % mod == 0 ? pow(x, p % (mod - 1)) : pow(x, p % (mod - 1) + mod - 1);
}
inline void sieve() {
  mu[1] = 1;
  for (register long long i = 2; i <= 100000; ++i) {
    if (!v[i]) {
      p[++num] = i;
      mu[i] = -1;
    }
    for (register long long j = 1; j <= num && p[j] * i <= 100000; ++j) {
      v[i * p[j]] = 1;
      if (i % p[j] == 0) {
        mu[i * p[j]] = 0;
        break;
      }
      mu[i * p[j]] = -mu[i];
    }
  }
}
signed main() {
  long long m = read(), ans = 0;
  for (register long long i = 1; i <= m; ++i) {
    long long x = read();
    freq[x] = read();
  }
  sieve();
  for (register long long i = 1; i <= 100000; ++i) {
    long long cnt = 0, sum = 0;
    f[i] = 0;
    for (register long long j = i; j <= 100000; j += i)
      cnt = cnt + freq[j], sum = (sum + j * freq[j] % mod) % mod;
    long long tmp1 = (cnt - 1) % mod * calc(2, cnt - 2) % mod,
              tmp2 = ((cnt - 2) % mod * calc(2, cnt - 3) % mod +
                      calc(2, cnt - 2)) %
                     mod;
    for (register long long j = i; j <= 100000; j += i) {
      if (freq[j] == 0) continue;
      f[i] = (f[i] + j * j % mod * tmp1 % mod * freq[j] % mod) % mod;
      f[i] = (f[i] + j * j % mod * tmp2 % mod *
                         (freq[j] * (freq[j] - 1) % mod) % mod) %
             mod;
      f[i] = (f[i] + (sum - j * freq[j] % mod) % mod * (freq[j] * j % mod) %
                         mod * tmp2 % mod) %
             mod;
    }
    ans = (ans + f[i] * mu[i] % mod) % mod;
  }
  printf("%lld\n", (ans % mod + mod) % mod);
  return 0;
}
