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;
const int N = 100005;
const int mod = 998244353;
bool np[N];
int pk, prime[N], mu[N];
void get_p(int n) {
  np[1] = true;
  mu[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!np[i]) {
      prime[pk++] = i;
      mu[i] = -1;
    }
    for (int j = 0, k; (k = i * prime[j]) <= n; j++) {
      np[k] = true;
      if (i % prime[j] == 0) {
        mu[k] = 0;
        break;
      }
      mu[k] = -mu[i];
    }
  }
}
long long ksm(long long a, long long b) {
  if (b < 0) return 0;
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
int freq[N], n = N - 5, m, f[N];
long long cal(int i) {
  long long now = 0, res = 0, g = 0;
  for (int j = i; j <= n; j += i)
    now += freq[j], g += (long long)j * freq[j] % mod;
  if (now < 2) return 0;
  long long p1 = ksm(2, now - 2), p2 = ksm(2, now - 3);
  long long s1 = (now - 1) % mod * p1 % mod,
            s2 = ((now - 2) % mod * p2 % mod + p1) % mod;
  for (int x = i; x <= n; x += i) {
    res += (long long)x * x % mod * s1 % mod * freq[x] % mod;
    res +=
        (long long)x * x % mod * s2 % mod * freq[x] % mod * (freq[x] - 1) % mod;
    res += (long long)x * freq[x] % mod * ((g - (long long)x * freq[x]) % mod) %
           mod * s2 % mod;
  }
  return res;
}
int main() {
  scanf("%d", &m);
  get_p(n);
  for (int i = 1; i <= m; i++) {
    int o, p;
    scanf("%d %d", &o, &p);
    freq[o] = p;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (mu[i] == 0) continue;
    ans += mu[i] * cal(i);
  }
  ans = (ans % mod + mod) % mod;
  printf("%lld\n", ans);
  return 0;
}
