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 gi() {
  int res = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && !isdigit(ch)) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
  return res * w;
}
const int Mod = 998244353;
int fpow(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = 1ll * res * x % Mod;
    x = 1ll * x * x % Mod, y >>= 1;
  }
  return res;
}
const int MAX_N = 1e5 + 5;
int N, M, a[MAX_N], b[MAX_N], c[MAX_N];
bool nprime[MAX_N];
int mu[MAX_N], prime[MAX_N], num;
void sieve() {
  mu[1] = 1;
  for (int i = 2; i <= N; i++) {
    if (!nprime[i]) prime[++num] = i, mu[i] = Mod - 1;
    for (int j = 1; j <= num && i * prime[j] <= N; j++) {
      nprime[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
      mu[i * prime[j]] = Mod - mu[i];
    }
  }
}
vector<pair<int, int> > vec[MAX_N];
int solve(vector<pair<int, int> > &pot) {
  if (!pot.size()) return 0;
  int res = 0, s1 = 0, s2 = 0;
  long long cnt = 0;
  for (auto it : pot) cnt += it.second;
  for (auto it : pot) s1 = (s1 + 1ll * it.first * it.second) % Mod;
  s1 = 1ll * s1 * s1 % Mod;
  for (auto it : pot)
    s2 = (s2 + 1ll * it.first * it.first % Mod * it.second) % Mod;
  s1 = (s1 - s2 + Mod) % Mod;
  int pw1 = fpow(2, (cnt - 3 + Mod - 1) % (Mod - 1)), pw2 = 2ll * pw1 % Mod;
  res = (res + (cnt - 1) % Mod * pw2 % Mod * s2) % Mod;
  if (cnt > 1)
    res = (res + ((cnt - 2 + Mod) % Mod * pw1 + pw2) % Mod * s1) % Mod;
  return res;
}
int main() {
  M = gi();
  for (int i = 1; i <= M; i++) {
    a[i] = gi(), b[i] = gi(), N = max(N, a[i]);
    c[a[i]] = b[i];
  }
  sieve();
  for (int i = 1; i <= N; i++)
    for (int j = i; j <= N; j += i)
      if (c[j]) vec[i].emplace_back(j, c[j]);
  int ans = 0;
  for (int i = 1; i <= N; i++)
    if (mu[i]) ans = (ans + 1ll * mu[i] * solve(vec[i])) % Mod;
  printf("%d\n", ans);
  return 0;
}