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 int mod = 998244353;
inline int addmod(int x) { return x >= mod ? x - mod : x; }
inline int submod(int x) { return x < 0 ? x + mod : x; }
int fpow(int x, long long y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = 1ll * ans * x % mod;
    x = 1ll * x * x % mod;
    y /= 2;
  }
  return ans;
}
int n, a[100005], pn = 1e5, mu[100005], p[100005], prime[100005], pt;
int pw[100005];
inline int F(int x, int y) {
  if (!x) return 1;
  return addmod(1ll * y * fpow(2, x - 1) % mod + fpow(2, x));
}
int solve(int ct, int cct, int sum, int sum2) {
  if (ct <= 1) return 0;
  return addmod(1ll * submod(1ll * sum * sum % mod - sum2) *
                    F(ct - 2, cct - 2) % mod +
                1ll * sum2 * (cct - 1) % mod * fpow(2, ct - 2) % mod);
}
int main() {
  pw[0] = 1;
  mu[1] = 1;
  for (int i = 1; i <= pn; i++) pw[i] = 2 * pw[i - 1] % mod;
  for (int i = 2; i <= pn; i++) {
    if (!p[i]) prime[++pt] = i, mu[i] = -1;
    for (int j = 1; j <= pt && i * prime[j] <= pn; j++) {
      p[i * prime[j]] = 1;
      if (i % prime[j] == 0) {
        mu[i * prime[j]] = 0;
        break;
      }
      mu[i * prime[j]] = -mu[i];
    }
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x] = y;
  }
  int ans = 0;
  for (int i = 1; i <= pn; i++)
    if (mu[i]) {
      int sum = 0, sum2 = 0;
      int ct = 0, cct = 0;
      for (int j = i; j <= pn; j += i) {
        ct = ct + a[j];
        while (ct > mod + 1000) ct -= (mod - 1);
        cct = (cct + a[j]) % mod;
        sum = addmod(sum + 1ll * j * a[j] % mod);
        sum2 = addmod(sum2 + 1ll * j * j % mod * a[j] % mod);
      }
      int q = solve(ct, cct, sum, sum2);
      if (mu[i] == 1)
        ans = addmod(ans + q);
      else if (mu[i] == -1)
        ans = submod(ans - q);
    }
  printf("%d\n", ans);
  return 0;
}