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;
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
T abs(T x) {
  return x < 0 ? -x : x;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
bool chmin(T &x, const T &y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template <typename T>
bool chmax(T &x, const T &y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}
auto random_address = [] {
  char *p = new char;
  delete p;
  return (uint64_t)p;
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count() *
            (random_address() | 1));
mt19937_64 rngll(chrono::steady_clock::now().time_since_epoch().count() *
                 (random_address() | 1));
const int MOD = 998244353;
void addmod(long long &x, long long d) {
  x += d;
  if (x >= MOD) {
    x -= MOD;
  }
  if (x < 0) {
    x += MOD;
  }
}
long long powmod(long long a, long long b) {
  long long ret = 1;
  long long p = a;
  while (b) {
    if (b & 1) {
      ret = ret * p % MOD;
    }
    p = p * p % MOD;
    b >>= 1;
  }
  return ret;
}
long long divmod(long long a, long long b) {
  return a * powmod(b, MOD - 2) % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m;
  cin >> m;
  const int n = 1e+5;
  vector<long long> sum(n + 1, 0);
  vector<long long> sum1(n + 1, 0);
  vector<long long> sum2(n + 1, 0);
  vector<long long> cnt(n + 1, 0);
  for (int i = 0; i < m; ++i) {
    long long x, f;
    cin >> x >> f;
    long long s = x * f % MOD;
    long long s1 = x * x % MOD * f % MOD;
    long long s2 = x * x % MOD * ((f - 1) * f % MOD) % MOD;
    auto add = [&](int i) {
      addmod(sum2[i], (s2 + 2 * s * sum[i]) % MOD);
      addmod(sum1[i], s1);
      addmod(sum[i], s);
      cnt[i] += f;
    };
    for (int j = 1; j * j <= x; ++j) {
      if (x % j) {
        continue;
      }
      add(j);
      if (x / j != j) {
        add(x / j);
      }
    }
  }
  vector<long long> f(n + 1, 0);
  for (int i = n; i >= 1; --i) {
    if (!cnt[i]) {
      continue;
    }
    long long &ret = f[i];
    long long k = cnt[i];
    long long p3, p2;
    p3 = p2 = 0;
    if (k > 2) {
      p3 = powmod(2, k - 3);
      p2 = p3 * 2 % MOD;
    } else if (k > 1) {
      p2 = powmod(2, k - 2);
    }
    if (k > 1) {
      addmod(ret, p2 * ((k - 1) % MOD) % MOD * sum1[i] % MOD);
      addmod(ret, p2 % MOD * sum2[i] % MOD);
    }
    if (k > 2) {
      addmod(ret, p3 * ((k - 2) % MOD) % MOD * sum2[i] % MOD);
    }
    for (int j = i + i; j <= n; j += i) {
      addmod(ret, -f[j]);
    }
  }
  cout << f[1] << endl;
  return 0;
}