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;
mt19937 mt_rand(
    chrono::high_resolution_clock::now().time_since_epoch().count());
const int INF = 2e9;
const long long ML = 4e18;
long long Pow(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = (res * x) % 998244353;
    x = x * x % 998244353;
    p >>= 1;
  }
  return res;
}
long long count1(long long k) {
  if (k == 1) return 0;
  long long r = (k - 1) % 998244353 * Pow(2, k - 2) % 998244353;
  return r % 998244353;
}
long long count2(long long k) {
  if (k < 3) return 1;
  long long x = Pow(2, k - 3), y = x * 2 % 998244353;
  long long r = y + (k - 2) % 998244353 * x % 998244353;
  return r % 998244353;
}
long long a[100005], cnt[100005], sum[100005];
vector<long long> va[100005];
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x] = y;
  }
  for (int i = (1); i < (100005); ++i) {
    for (int j = i; j < 100005; j += i) {
      if (a[j]) {
        cnt[i] = cnt[i] + a[j];
        sum[i] = (sum[i] + a[j] * j) % 998244353;
        va[i].push_back(j);
      }
    }
  }
  vector<long long> ans(100005, 0);
  for (int i = (1); i < (100005); ++i) {
    if (cnt[i] < 2) continue;
    int x = count1(cnt[i]), y = count2(cnt[i]);
    for (long long j : va[i]) {
      ans[i] = (ans[i] + x * j % 998244353 * j % 998244353 * a[j] % 998244353 +
                y * j % 998244353 * ((sum[i] - j + 998244353) % 998244353) %
                    998244353 * a[j] % 998244353) %
               998244353;
    }
  }
  for (int i = (100005 - 1); i >= (1); --i) {
    for (int j = i + i; j < 100005; j += i) {
      ans[i] = (ans[i] - ans[j] + 998244353) % 998244353;
    }
  }
  printf("%lld\n", ans[1]);
}
int main() {
  clock_t start, finish;
  start = clock();
  solve();
  finish = clock();
  return 0;
}
