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;
const int N = (int)1e5;
long long modpow(long long b, long long p) {
  if (p == 0) {
    return 1;
  }
  long long ans = modpow((b * b) % MOD, p / 2);
  if (p % 2 == 1) {
    ans = (ans * b) % MOD;
  }
  return ans;
}
long long mul(long long a, long long b) { return (a * b) % MOD; }
long long add(long long a, long long b) {
  if (a + b >= MOD) {
    return a + b - MOD;
  }
  return a + b;
}
long long sub(long long a, long long b) {
  if (a - b < 0) {
    return a - b + MOD;
  }
  return a - b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m;
  cin >> m;
  vector<long long> squared_sum(N + 1), k(N + 1), sum(N + 1);
  for (int i = 0; i < m; i++) {
    long long a, freq;
    cin >> a >> freq;
    for (int j = 1; j * j <= a; j++) {
      if (a % j == 0) {
        squared_sum[j] = add(squared_sum[j], mul(a, mul(a, freq)));
        k[j] += freq;
        sum[j] = add(sum[j], mul(a, freq));
        if (a != j * j) {
          long long x = a / j;
          squared_sum[x] = add(squared_sum[x], mul(a, mul(a, freq)));
          k[x] += freq;
          sum[x] = add(sum[x], mul(a, freq));
        }
      }
    }
  }
  vector<long long> ans(N + 1, 0);
  for (int i = N; i >= 1; i--) {
    if (k[i] < 2) {
      continue;
    }
    if (k[i] == 2) {
      ans[i] = mul(sum[i], sum[i]);
    } else {
      ans[i] =
          add(mul(squared_sum[i], mul(modpow(2, k[i] - 2), sub(k[i] % MOD, 1))),
              mul(sub(mul(sum[i], sum[i]), squared_sum[i]),
                  add(mul(modpow(2, k[i] - 3), sub(k[i] % MOD, 2)),
                      modpow(2, k[i] - 2))));
    }
    for (int j = 2 * i; j <= N; j += i) {
      ans[i] = sub(ans[i], ans[j]);
    }
  }
  cout << ans[1] << '\n';
  return 0;
}
