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;
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
const long long inf = 4e18;
const int infi = 1e9;
long long i, j, n, m, k, qq = 1, fr, to, w, x, y, mod = 998244353;
char ch;
void addmod(long long &x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
long long bpow(long long n, long long x) {
  if (x == 0) return 1;
  long long cr = bpow(n, x / 2);
  cr = cr * cr % mod;
  if (x & 1)
    return cr * n % mod;
  else
    return cr;
}
void solve() {
  cin >> m;
  n = 1e5;
  vector<long long> sum(n + 1, 0), sum1(n + 1, 0), sum2(n + 1, 0),
      cnt(n + 1, 0);
  for (long long i = 0; i < m; i++) {
    long long x, first;
    cin >> x >> first;
    long long second = x * first % mod;
    long long s1 = x * first % mod * x % mod;
    long long s2 = x * x % mod * first % mod * (first - 1) % mod;
    auto add = [&](long long i) {
      addmod(sum2[i], (s2 + 2 * second * sum[i]) % mod);
      addmod(sum1[i], s1);
      addmod(sum[i], second);
      cnt[i] += first;
    };
    for (long long j = 1; j * j <= x; j++) {
      if (x % j != 0) continue;
      add(j);
      if (j * j != x) add(x / j);
    }
  }
  vector<long long> first(n + 1, 0);
  for (long long i = n; i >= 1; i--) {
    if (cnt[i] < 1) continue;
    long long &ret = first[i];
    long long k = cnt[i];
    long long p2 = 0, p3 = 0;
    if (k > 2) {
      p3 = bpow(2, k - 3);
      p2 = p3 * 2 % mod;
    } else if (k > 1) {
      p2 = bpow(2, k - 2);
    }
    if (k > 1) {
      addmod(ret, p2 * ((k - 1) % mod) % mod * sum1[i] % mod);
      addmod(ret, p2 % mod * sum2[i] % mod);
    }
    if (k > 2) {
      addmod(ret, p3 * ((k - 2) % mod) % mod * sum2[i] % mod);
    }
    for (long long j = i + i; j <= n; j += i) {
      addmod(ret, -first[j]);
    }
  }
  cout << first[1] << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (qq == 0) cin >> qq;
  while (qq--) {
    solve();
  }
}