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 = 100003, mod = 998244353;
template <typename T>
void read(T &x) {
  int ch = getchar();
  x = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
void qmo(int &x) { x += x >> 31 & mod; }
template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) return a = b, 1;
  return 0;
}
int ksm(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = (long long)a * a % mod)
    if (b & 1) res = (long long)res * a % mod;
  return res;
}
int n, m, a[N], pri[N], tot, mu[N], ans;
bool notp[N];
void init(int n) {
  notp[0] = notp[1] = mu[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!notp[i]) {
      pri[tot++] = i;
      mu[i] = -1;
    }
    for (int j = 0; j < tot && i * pri[j] <= n; ++j) {
      notp[i * pri[j]] = true;
      if (i % pri[j])
        mu[i * pri[j]] = -mu[i];
      else
        break;
    }
  }
}
int main() {
  read(m);
  while (m--) {
    int p, v;
    read(p);
    read(v);
    chmax(n, p);
    a[p] = v;
  }
  init(n);
  for (int d = 1; d <= n; ++d)
    if (mu[d]) {
      int sum1 = 0, sum2 = 0;
      long long cnt = 0;
      for (int i = d; i <= n; i += d) {
        cnt += a[i];
        sum1 = (sum1 + (long long)i * a[i]) % mod;
        sum2 = (sum2 + (long long)i * i % mod * a[i]) % mod;
      }
      int tmp = (cnt % mod * sum1 % mod * sum1 + (cnt - 2) % mod * sum2) % mod *
                ksm(2, (cnt + mod - 4) % (mod - 1)) % mod;
      if (mu[d] == 1)
        qmo(ans += tmp - mod);
      else
        qmo(ans -= tmp);
    }
  printf("%d\n", ans);
}
