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 long long MN = 2e5 + 5, N = 1e5;
const long long mod = 998244353;
long long M, freq[MN], mu[MN];
inline void inc(long long &x, long long y) {
  x = x + y < mod ? x + y : x + y - mod;
}
inline long long qPow(long long a, long long b) {
  long long c = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) c = 1ll * c * a % mod;
  return c;
}
signed main() {
  scanf("%lld", &M);
  for (long long i = 1; i <= M; ++i) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    freq[a] = b;
  }
  mu[1] = 1;
  for (long long i = 1; i <= N; ++i)
    for (long long j = 2 * i; j <= N; j += i) mu[j] -= mu[i];
  long long ans = 0;
  for (long long i = 1; i <= N; ++i) {
    long long s = 0, sq = 0, K = 0;
    for (long long j = i; j <= N; j += i) {
      K += freq[j];
      inc(s, 1ll * j * freq[j] % mod);
      inc(sq, 1ll * j * j % mod * freq[j] % mod);
    }
    if (K < 2) continue;
    long long t1 = 1ll * sq * qPow(2, K - 2) % mod * ((K - 1) % mod) % mod;
    long long n2 = (1ll * s * s % mod - sq + mod) % mod;
    long long t2 = qPow(2, K - 2);
    if (K >= 3) t2 = (t2 + 1ll * ((K - 2) % mod) * qPow(2, K - 3) % mod) % mod;
    t2 = 1ll * t2 * n2 % mod;
    inc(ans, 1ll * (1ll * ((t1 + t2) % mod) * mu[i] + mod) % mod);
  }
  printf("%lld\n", ans);
  return 0;
}
