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;
long long ex(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % (long long)(998244353);
    a = (a * a) % (long long)(998244353), b /= 2;
  }
  return ans;
}
inline long long add(long long a, long long b) {
  a = a % (long long)(998244353) + b % (long long)(998244353);
  if (a >= (long long)(998244353)) a -= (long long)(998244353);
  return a;
}
inline long long sub(long long a, long long b) {
  a = a % (long long)(998244353) - b % (long long)(998244353);
  if (a < 0) a += (long long)(998244353);
  return a;
}
inline long long mul(long long a, long long b) {
  a %= (long long)(998244353), b %= (long long)(998244353);
  return (a * b) % (long long)(998244353);
}
long long cnt[100010], sum[100010], sum2[100010];
long long ans[100010];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long m;
  cin >> m;
  for (long long i = 0; i < m; ++i) {
    long long val, ct;
    cin >> val >> ct;
    long long x = mul(val, ct), y = mul(val, x);
    for (long long j = 1; j * j <= val; ++j) {
      if (val % j) continue;
      long long p = j;
      cnt[p] += ct;
      sum[p] = add(sum[p], x);
      sum2[p] = add(sum2[p], y);
      if (j * j == val) continue;
      p = val / j;
      cnt[p] += ct;
      sum[p] = add(sum[p], x);
      sum2[p] = add(sum2[p], y);
    }
  }
  for (long long i = 1; i < 100010; ++i) {
    sum[i] = mul(sum[i], sum[i]);
    sum[i] = sub(sum[i], sum2[i]);
  }
  for (long long i = 100010 - 1; i > 0; --i) {
    long long now = 0, x;
    if (cnt[i] >= 2) {
      if (cnt[i] == 2)
        x = 1;
      else
        x = mul(cnt[i], ex(2, cnt[i] - 3));
      now = add(now, mul(sum[i], x));
    }
    if (cnt[i] > 1) {
      x = mul(cnt[i] - 1, ex(2, cnt[i] - 2));
      now = add(now, mul(sum2[i], x));
    }
    for (long long j = 2 * i; j < 100010; j += i) now = sub(now, ans[j]);
    ans[i] = now;
  }
  cout << ans[1];
  return 0;
}
