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;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
inline void print(int x) {
  if (x < 0) putchar('-'), x = ~x + 1;
  if (x >= 10) print(x / 10);
  putchar((x % 10) | 48);
}
int m;
int a[100010], freq[100010];
int mu[100010];
int pr[100010];
bool vis[100010];
int cnt;
int ans;
const int N = 100000;
const int mod = 998244353;
void getmu() {
  mu[1] = 1;
  for (int i = 2; i <= N; ++i) {
    if (!vis[i]) pr[++cnt] = i, mu[i] = -1;
    for (int j = 1; j <= cnt && 1ll * pr[j] * i <= N; ++j) {
      vis[pr[j] * i] = 1;
      if (i % pr[j] == 0) {
        mu[i * pr[j]] = 0;
        break;
      } else
        mu[i * pr[j]] = -mu[i];
    }
  }
}
inline int qpow(int x, int k) {
  int res = 1;
  while (k) {
    if (k & 1) res = 1ll * res * x % mod;
    x = 1ll * x * x % mod;
    k >>= 1;
  }
  return res;
}
int main() {
  m = read();
  for (int i = 1; i <= m; ++i) a[i] = read(), freq[a[i]] = read();
  getmu();
  for (int i = 1; i <= N; ++i) {
    if (mu[i]) {
      long long c = 0;
      int sum = 0, squ = 0;
      for (int j = i; j <= N; j += i)
        (sum += 1ll * freq[j] % mod * j % mod) %= mod,
            (squ += 1ll * freq[j] % mod * j % mod * j % mod) %= mod,
            c += freq[j];
      if (c <= 1) continue;
      sum = 1ll * sum * sum % mod;
      sum = (sum - squ + mod) % mod;
      int S = 0;
      if (c >= 3)
        S = 1ll * sum * (1ll * c % mod * qpow(2, (c - 3) % (mod - 1)) % mod) %
            mod;
      else
        S = sum;
      (S += 1ll * (c - 1) % mod * squ % mod * qpow(2, (c - 2) % (mod - 1)) %
            mod) %= mod;
      (ans += 1ll * mu[i] * S % mod) %= mod;
    }
  }
  print((ans + mod) % mod);
}