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 MOD = 998244353;
int N = 100000;
long long A[101010];
int mu[101010];
long long pw(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
int main() {
  int M;
  scanf("%d", &M);
  for (int i = 1; i <= M; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    A[a] = b;
  }
  mu[1] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = i * 2; j <= N; j += i) mu[j] -= mu[i];
  }
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    long long s = 0, sq = 0;
    long long K = 0;
    for (int j = i; j <= N; j += i) {
      K += A[j];
      s = (s + A[j] * j) % MOD;
      sq = (sq + A[j] * j % MOD * j) % MOD;
    }
    if (K < 2) continue;
    long long t1 = sq * pw(2, K - 2) % MOD * ((K - 1) % MOD) % MOD;
    long long n2 = (s * s + MOD - sq) % MOD;
    long long t2 = pw(2, K - 2);
    if (K >= 3) t2 = (t2 + ((K - 2) % MOD) * pw(2, K - 3)) % MOD;
    t2 = t2 * n2 % MOD;
    ans = (ans + ((t1 + t2) % MOD * mu[i] + MOD)) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}
