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 = 100005;
const long long mod = (long long)998244353;
long long pot[N], cnt[N], s[N], s2[N], sp[N], dp[N];
vector<int> q21joe21i[N];
int m;
long long fpot(long long x, long long y) {
  if (!y) return 1;
  long long pa = fpot(x, y / 2);
  if (y & 1) return ((pa * pa) % mod) * x % mod;
  return pa * pa % mod;
}
int32_t main() {
  pot[0] = 1;
  for (int i = 1; i < N; i++) {
    pot[i] = (pot[i - 1] * 2) % mod;
    for (int j = i; j < N; j += i) q21joe21i[j].push_back(i);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    long long sq = a * a % mod * b % mod;
    long long sq2 = a * a % mod * (b * (b - 1) % mod) % mod;
    for (auto w : q21joe21i[a]) {
      cnt[w] += b;
      sp[w] = (sp[w] + sq2 + (((2 * a * b) % mod) * s[w])) % mod;
      s[w] = (s[w] + a * b) % mod;
      s2[w] = (s2[w] + sq) % mod;
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    if (cnt[i]) {
      long long t = cnt[i];
      long long fa = (t > 2 ? fpot(2, t - 3) : 0),
                af = (t > 1 ? fpot(2, t - 2) : 0);
      if (t > 1) {
        dp[i] = (dp[i] + (((af * ((t - 1) % mod)) % mod) * s2[i]) % mod) % mod;
        dp[i] = (dp[i] + (af * sp[i]) % mod) % mod;
      }
      if (t > 2) {
        dp[i] = (dp[i] + (((fa * ((t - 2) % mod)) % mod) * sp[i]) % mod) % mod;
      }
      for (int j = 2 * i; j < N; j += i) {
        dp[i] = ((dp[i] - dp[j]) % mod + mod) % mod;
      }
    }
  }
  printf("%lld\n", dp[1]);
}
