Problem: 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.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int MOD = 998244353;
const int MAXVAL = 100000;
const int INV2 = (MOD + 1) / 2;
int pw(int x, long long n) {
  int ret = 1;
  while (true) {
    if (n & 1) ret = (long long)ret * x % MOD;
    if ((n >>= 1) == 0) return ret;
    x = (long long)x * x % MOD;
  }
}
int n;
int val[MAXN], freq[MAXN];
int calc1(long long n) {
  if (n == 0) return 0;
  return (long long)pw(2, n - 1) * (n % MOD) % MOD;
}
int calc2(long long n) { return (calc1(n) + pw(2, n)) % MOD; }
int calc(vector<int> ids) {
  if (((int)(ids).size()) == 0) return 0;
  long long cnt = 0;
  int sum = 0;
  int sumsq = 0;
  for (int i = (0); i < (((int)(ids).size())); ++i) {
    int idx = ids[i];
    cnt += freq[idx];
    sum = (sum + (long long)freq[idx] * val[idx]) % MOD;
    sumsq = (sumsq + (long long)freq[idx] * val[idx] % MOD * val[idx]) % MOD;
  }
  int sumpair = ((long long)sum * sum + MOD - sumsq) % MOD;
  int sqmlt = calc1(cnt - 1);
  int pairmlt = cnt == 1 ? 0 : calc2(cnt - 2);
  return ((long long)sumsq * sqmlt + (long long)sumpair * pairmlt) % MOD;
}
int who[MAXVAL + 1];
int solve() {
  vector<int> all(n);
  for (int i = (0); i < (n); ++i) all[i] = i;
  vector<bool> isprime(MAXVAL + 1, true);
  isprime[0] = isprime[1] = false;
  for (int i = (2); i < (((int)(isprime).size())); ++i)
    if (isprime[i])
      for (int j = i + i; j < ((int)(isprime).size()); j += i)
        isprime[j] = false;
  vector<int> mu(MAXVAL + 1, +1);
  for (int i = (0); i < (((int)(mu).size())); ++i)
    if (isprime[i]) {
      for (int j = i; j < ((int)(mu).size()); j += i) mu[j] = -mu[j];
      if ((long long)i * i < ((int)(mu).size()))
        for (int j = i * i; j < ((int)(mu).size()); j += i * i) mu[j] = 0;
    }
  for (int i = (0); i <= (MAXVAL); ++i) who[i] = -1;
  for (int i = (0); i < (n); ++i) {
    assert(who[val[i]] == -1);
    who[val[i]] = i;
  }
  int ret = 0;
  for (int i = (1); i < (((int)(mu).size())); ++i)
    if (mu[i] != 0) {
      vector<int> lst;
      for (int j = i; j <= MAXVAL; j += i)
        if (who[j] != -1) lst.push_back(who[j]);
      int cur = calc(lst);
      ret += mu[i] * cur;
      ret = (ret % MOD + MOD) % MOD;
    }
  return ret;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d%d", &val[i], &freq[i]);
  printf("%d\n", solve());
}
int main() {
  run();
  return 0;
}