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;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  const int MAX = 1e5 + 5;
  int m;
  cin >> m;
  vector<long long> sum(MAX);
  vector<long long> sum2(MAX);
  vector<long long> freq(MAX);
  const int MOD = 998244353;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    cin >> freq[x];
    sum[x] += 1ll * x * freq[x] % MOD;
    sum2[x] += 1ll * x * x % MOD * freq[x] % MOD;
  }
  for (int i = 1; i < MAX; i++) {
    for (int j = i + i; j < MAX; j += i) {
      freq[i] += freq[j];
      sum[i] += sum[j];
      sum[i] %= MOD;
      sum2[i] += sum2[j];
      sum2[i] %= MOD;
    }
  }
  const auto Power = [&](int a, long long x) {
    int res = 1;
    int mul = a;
    while (x) {
      if (x & 1) {
        res = 1ll * mul * res % MOD;
      }
      mul = 1ll * mul * mul % MOD;
      x /= 2;
    }
    return res;
  };
  vector<int> dp(MAX);
  for (int i = MAX - 1; i > 0; i--) {
    dp[i] = 0;
    if (freq[i] >= 2) {
      dp[i] += 1ll * sum2[i] * Power(2, freq[i] - 2) % MOD *
               (freq[i] % MOD - 1) % MOD;
      dp[i] %= MOD;
      dp[i] += 1ll * (1ll * sum[i] * sum[i] % MOD - sum2[i]) % MOD *
               (freq[i] == 2
                    ? 1
                    : (1ll * Power(2, freq[i] - 3) * (freq[i] % MOD) % MOD)) %
               MOD;
      dp[i] %= MOD;
    }
    for (int j = i + i; j < MAX; j += i) {
      dp[i] -= dp[j];
      dp[i] %= MOD;
    }
    if (dp[i] < 0) {
      dp[i] += MOD;
    }
  }
  cout << dp[1] << "\n";
  return 0;
}
