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 mod = 998244353;
const int N = 1e5 + 5;
int a[N], freq[N], ans[N], sum[N], sumsquare[N];
long long num[N];
int qpow(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 main() {
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &a[i], &freq[i]);
    num[a[i]] = num[a[i]] + freq[i];
    sum[a[i]] = (sum[a[i]] + 1ll * a[i] * freq[i] % mod) % mod;
    sumsquare[a[i]] =
        (sumsquare[a[i]] + 1ll * a[i] * a[i] % mod * freq[i] % mod) % mod;
  }
  for (int i = 1; i < N; i++) {
    for (int j = 2 * i; j < N; j += i) {
      num[i] = num[i] + num[j];
      sum[i] = (sum[i] + sum[j]) % mod;
      sumsquare[i] = (sumsquare[i] + sumsquare[j]) % mod;
    }
  }
  for (int i = 1; i < N; i++) {
    long long k = num[i];
    if (k >= 2) {
      ans[i] = (ans[i] + 1ll * sumsquare[i] * qpow(2, k - 2) % mod *
                             ((k - 1) % mod) % mod) %
               mod;
      int temp = 0;
      if (k >= 3) {
        temp = (temp + 1ll * qpow(2, k - 3) * ((k - 2) % mod) % mod) % mod;
      }
      temp = (temp + 1ll * qpow(2, k - 2) % mod) % mod;
      ans[i] =
          (ans[i] + 1ll * (1ll * sum[i] * sum[i] % mod - sumsquare[i] + mod) %
                        mod * temp % mod) %
          mod;
    }
  }
  for (int i = N - 1; i >= 1; i--) {
    for (int j = 2 * i; j < N; j += i) {
      ans[i] = (ans[i] - ans[j] + mod) % mod;
    }
  }
  printf("%d\n", ans[1]);
  return 0;
}
