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 int mod = 998244353;
const int N = 100005;
long long dp[N];
vector<pair<long long, long long> > member[N];
int add(int a, int b) { return ((a += b) >= mod) ? a - mod : a; }
void adding(int &a, int b) {
  if ((a += b) >= mod) a -= mod;
}
long long pw(long long a, long long b) {
  if (b < 0) b = (-b * (mod - 2)) % (mod - 1);
  if (b >= mod - 1) b %= (mod - 1);
  long long res = a, ans = 1;
  for (long long i = 1; i <= b; i <<= 1, res = res * res % mod) {
    if (i & b) ans = ans * res % mod;
  }
  return ans;
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int t = (0), i2 = (n - 1); t <= i2; ++t) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    member[a].push_back(pair<long long, long long>(a, b));
  }
  for (int i = (1), i2 = (100000); i <= i2; ++i) {
    long long f = 0;
    long long sum = 0;
    long long sump = 0;
    long long sum2 = 0;
    for (int j = i; j <= 100000; j += i) {
      for (pair<long long, long long> &e : member[j]) {
        f += e.second;
        sump += sum * (e.first * e.second % mod) % mod;
        sump %= mod;
        sump += e.second * (e.second - 1) / 2 % mod *
                (e.first * e.first % mod) % mod;
        sum = (sum + e.first * e.second) % mod;
        sum2 = (sum2 + e.first * e.first % mod * e.second) % mod;
      }
    }
    if (f == 0) continue;
    long long term = (f - 1) % mod * pw(2, f - 2) % mod;
    long long first_half = sum2 * term % mod;
    long long termp = f % mod * pw(2, f - 3) % mod;
    long long second_half = 2 * sump * termp % mod;
    dp[i] = (first_half + second_half) % mod;
  }
  for (int i = 100000; i >= 1; --i) {
    for (int j = i + i; j <= 100000; j += i) {
      dp[i] -= dp[j];
      if (dp[i] < 0) dp[i] += mod;
    }
  }
  printf("%lld", dp[1]);
}
int main() {
  solve();
  return 0;
}
