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;
using namespace std;
const int maxn = 100000 + 10;
const long long inf = 1e9;
const int maxm = 15;
const long long mod = 998244353;
long long mu[maxn];
int vis[maxn], tot;
vector<int> p;
long long inv2;
long long cnt[maxn], sum[maxn], sumq[maxn];
inline long long fpow(long long a, long long b) {
  long long ans(1);
  for (; b;) {
    if (b & 1) ans = ans * a % mod;
    b >>= 1, a = a * a % mod;
  }
  return ans;
}
inline void init() {
  mu[1] = 1;
  for (auto i = (2); i < (maxn); ++i) {
    if (!vis[i]) tot++, p.push_back(i), mu[i] = -1;
    for (int j = 0; j < tot && 1LL * p[j] * i < maxn; ++j) {
      vis[p[j] * i] = 1;
      if (i % p[j] == 0) break;
      mu[p[j] * i] = -mu[i];
    }
  }
  for (auto i = (2); i < (maxn); ++i) {
    mu[i] += mod;
    if (mu[i] >= mod) mu[i] -= mod;
  }
}
inline void solve() {
  long long ans = 0;
  for (int d = 1; d < maxn; ++d) {
    if (mu[d] == 0) continue;
    if (cnt[d] >= 2) {
      long long tmp = sumq[d];
      tmp = tmp * ((cnt[d] - 1) % mod) % mod;
      tmp = tmp * fpow(2, (cnt[d] - 2) % (mod - 1)) % mod;
      ans = ans + (tmp * mu[d] % mod);
      if (ans >= mod) ans -= mod;
      tmp = (sum[d] * sum[d] % mod) - sumq[d];
      if (tmp < 0) tmp += mod;
      tmp = tmp * (cnt[d] % mod) % mod;
      long long co;
      if (cnt[d] == 2)
        co = inv2;
      else
        co = fpow(2, (cnt[d] - 3) % (mod - 1));
      tmp = tmp * co % mod;
      ans = ans + (tmp * mu[d] % mod);
      if (ans >= mod) ans -= mod;
    }
  }
  printf("%lld\n", ans);
}
int main(void) {
  init();
  inv2 = fpow(2, mod - 2);
  int m, a, freq;
  scanf("%d", &(m));
  for (; m--;) {
    scanf("%d", &(a)), scanf("%d", &(freq));
    cnt[a] += freq;
    sum[a] += (1LL * freq * a) % mod;
    if (sum[a] >= mod) sum[a] -= mod;
    sumq[a] += (1LL * freq * ((1LL * a * a) % mod)) % mod;
    if (sumq[a] >= mod) sumq[a] -= mod;
  }
  for (auto d = (1); d < (maxn); ++d) {
    for (int j = d * 2; j < maxn; j += d) {
      cnt[d] += cnt[j];
      sum[d] += sum[j];
      sumq[d] += sumq[j];
      if (sum[d] >= mod) sum[d] -= mod;
      if (sumq[d] >= mod) sumq[d] -= mod;
    }
  }
  solve();
  return 0;
}