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;
int n;
int cnt[100007];
long long ans[100007];
long long fastpow(long long x, long long pw) {
  if (pw < 0) {
    return 0;
  }
  long long ret = 1;
  while (pw > 0) {
    if ((pw % 2) == 0) {
      x = (x * x) % 998244353;
      pw /= 2;
    } else {
      ret = (ret * x) % 998244353;
      --pw;
    }
  }
  return ret;
}
void input() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    cnt[x] = y;
  }
}
void solve() {
  for (int i = 100007 - 1; i >= 1; --i) {
    long long tot = 0;
    long long sm = 0;
    long long sq = 0;
    long long w = 0;
    for (int j = i; j < 100007; j += i) {
      tot += cnt[j];
      long long aux = (1LL * cnt[j] * j) % 998244353;
      w = (w + (2LL * sm * aux) % 998244353) % 998244353;
      long long pairs = (1LL * cnt[j] * (cnt[j] - 1)) % 998244353;
      w = (w + (((pairs * j) % 998244353) * j) % 998244353) % 998244353;
      sm = (sm + aux) % 998244353;
      sq =
          (sq + (((1LL * cnt[j] * j) % 998244353) * j) % 998244353) % 998244353;
    }
    if (tot == 0) {
      continue;
    }
    long long coef = fastpow(2, tot - 2);
    coef = (coef * ((tot - 1) % 998244353)) % 998244353;
    ans[i] = (coef * sq) % 998244353;
    coef = fastpow(2, tot - 3);
    coef = (coef * ((tot - 2) % 998244353)) % 998244353;
    coef = (coef + fastpow(2, tot - 2)) % 998244353;
    ans[i] = (ans[i] + (coef * w) % 998244353) % 998244353;
    for (int j = 2 * i; j < 100007; j += i) {
      ans[i] = (ans[i] - ans[j] + 998244353) % 998244353;
    }
  }
  printf("%I64d\n", ans[1]);
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  solve();
  return 0;
}