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 maxn = 1e5 + 5;
const int mod = 998244353;
inline int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
inline int mul(int a, int b) { return 1ll * a * b % mod; }
inline int mul(int a, int b, int c) { return 1ll * a * b % mod * c % mod; }
inline void inc(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
inline void dec(int &a, int b) {
  a -= b;
  if (a < 0) a += mod;
}
long long sf[maxn];
int sa1[maxn];
int sa2[maxn];
int f[maxn];
int _pow(int a, long long n) {
  int res = 1;
  while (n) {
    if (n & 1) res = mul(res, a);
    a = mul(a, a);
    n >>= 1;
  }
  return res;
}
int main(void) {
  int m;
  scanf("%d", &m);
  int n = 1e5;
  for (int i = 1; i <= m; i++) {
    int x, f;
    scanf("%d%d", &x, &f);
    sa1[x] = mul(x, f);
    sa2[x] = mul(x, x, f);
    sf[x] = f;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + i; j <= n; j += i) {
      sf[i] += sf[j];
      sa1[i] = add(sa1[i], sa1[j]);
      sa2[i] = add(sa2[i], sa2[j]);
    }
  }
  for (int i = n; i >= 1; i--) {
    if (sf[i] < 2) continue;
    int p1 = 0;
    int p2 = 0;
    int p3 = 0;
    int q1 = sa2[i];
    int q2 = 1ll * (1ll * sa1[i] * sa1[i] % mod - sa2[i] + mod) % mod;
    p1 = 1ll * (sf[i] - 1) % mod * _pow(2, sf[i] - 2) % mod;
    if (sf[i] > 2) p2 = 1ll * (sf[i] - 2) % mod * _pow(2, sf[i] - 3) % mod;
    p3 = _pow(2, sf[i] - 2);
    f[i] = 1ll * (1ll * p1 * q1 % mod + 1ll * (p2 + p3) % mod * q2 % mod) % mod;
    for (int j = i + i; j <= n; j += i) {
      f[i] = sub(f[i], f[j]);
    }
  }
  printf("%d\n", f[1]);
  return 0;
}
