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;
long long Pow(long long a, long long k, long long p) {
  long long ans = 1;
  while (k) {
    if (k & 1) ans = ans * a % p;
    k >>= 1;
    a = a * a % p;
  }
  return ans;
}
const int maxn = 233333;
bool isnt[maxn];
int prime[maxn];
int cnt = 0;
int mu[maxn];
void Sieve(int n) {
  isnt[1] = true;
  mu[1] = 1;
  cnt = 0;
  for (int i = 2; i <= n; i++) {
    if (!isnt[i]) {
      prime[++cnt] = i;
      mu[i] = -1;
    }
    for (int j = 1; j <= cnt; j++) {
      int x = i * prime[j];
      if (x > n) break;
      isnt[x] = 1;
      if (i % prime[j] == 0) {
        mu[x] = 0;
        break;
      } else {
        mu[x] = -mu[i];
      }
    }
  }
}
long long a[maxn], f[maxn];
vector<long long> bei[maxn];
int main() {
  Sieve(200000);
  long long n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld%lld", &a[i], &f[i]);
  }
  for (long long i = 1, j; i <= n; ++i) {
    for (j = 1; j * j < a[i]; ++j) {
      if (a[i] % j == 0) {
        bei[j].push_back(i);
        bei[a[i] / j].push_back(i);
      }
    }
    if (j * j == a[i]) bei[j].push_back(i);
  }
  long long ans = 0, cur;
  long long sum, sum2, sz = 0, ssz;
  for (int i = 1; i <= 100000; ++i) {
    sum = 0, sum2 = 0, sz = 0;
    for (auto id : bei[i]) {
      sz += f[id];
      sum = (sum + a[id] * f[id] % mod) % mod;
      sum2 = (sum2 + (a[id] * a[id] % mod) * f[id] % mod) % mod;
    }
    if (sz >= 3) {
      ssz = sz % mod;
      cur = (((sum * sum % mod) * ssz % mod + (ssz - 2) * sum2 % mod) % mod) *
            Pow(2, sz - 3, mod) % mod;
      ans = (ans + cur * mu[i]) % mod;
    } else if (sz == 2) {
      cur = sum * sum % mod;
      ans = (ans + sum * sum * mu[i] % mod) % mod;
    }
  }
  printf("%lld\n", (ans + mod) % mod);
}
