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>
#pragma GCC optimize("Ofast")
using namespace std;
constexpr long long mod = 998244353;
const long long INF = mod * mod;
const double eps = 1e-12;
const double pi = acosl(-1.0);
long long mod_pow(long long x, long long n, long long m = mod) {
  if (n < 0) {
    long long res = mod_pow(x, -n, m);
    return mod_pow(res, m - 2, m);
  }
  x %= m;
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
struct modint {
  long long n;
  modint() : n(0) { ; }
  modint(long long m) : n(m) {
    if (n >= mod)
      n %= mod;
    else if (n < 0)
      n = (n % mod + mod) % mod;
  }
  operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) {
  a.n += b.n;
  if (a.n >= mod) a.n -= mod;
  return a;
}
modint operator-=(modint& a, modint b) {
  a.n -= b.n;
  if (a.n < 0) a.n += mod;
  return a;
}
modint operator*=(modint& a, modint b) {
  a.n = ((long long)a.n * b.n) % mod;
  return a;
}
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, long long n) {
  if (n == 0) return modint(1);
  modint res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}
long long inv(long long a, long long p) {
  return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 2;
modint fact[max_n], factinv[max_n];
void init_f() {
  fact[0] = modint(1);
  for (int i = 0; i < max_n - 1; i++) {
    fact[i + 1] = fact[i] * modint(i + 1);
  }
  factinv[max_n - 1] = modint(1) / fact[max_n - 1];
  for (int i = max_n - 2; i >= 0; i--) {
    factinv[i] = factinv[i + 1] * modint(i + 1);
  }
}
modint comb(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return fact[a] * factinv[a - b];
}
modint calc(vector<pair<long long, long long> > v) {
  long long s = 0;
  for (int i = 0; i < v.size(); i++) s += v[i].second;
  if (s <= 1) return 0;
  modint c2 = (modint)s * (modint)mod_pow(2, s - 3);
  c2 *= 2;
  modint c1 = (modint)(s - 1) * (modint)mod_pow(2, s - 2);
  modint sum2 = 0;
  modint al2 = 0;
  for (int i = 0; i < v.size(); i++) {
    modint val = v[i].first;
    modint num = v[i].second * (v[i].second - 1) / 2;
    sum2 += num * val * val;
    sum2 += al2 * val * (modint)v[i].second;
    al2 += val * (modint)v[i].second;
  }
  modint sum1 = 0;
  for (int i = 0; i < v.size(); i++) {
    modint val = v[i].first;
    modint num = v[i].second;
    sum1 += val * val * num;
  }
  modint res = 0;
  res += c2 * sum2;
  res += c1 * sum1;
  return res;
}
vector<int> ch[1 << 17];
bool isp[1 << 17];
int meb[1 << 17];
void init() {
  for (int i = 1; i < (1 << 17); i++) {
    for (int j = i; j < (1 << 17); j += i) {
      ch[j].push_back(i);
    }
  }
  fill(isp + 2, isp + (1 << 17), true);
  fill(meb + 1, meb + (1 << 17), 1);
  for (int i = 2; i < (1 << 17); i++) {
    if (!isp[i]) continue;
    for (int j = i; j < (1 << 17); j += i) {
      meb[j] *= -1;
      if ((j / i) % i == 0) meb[j] = 0;
      isp[j] = false;
    }
  }
}
vector<pair<long long, long long> > memo[1 << 17];
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), f(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> f[i];
  for (int i = 0; i < n; i++) {
    for (int d : ch[a[i]]) {
      memo[d].push_back({a[i], f[i]});
    }
  }
  modint ans = 0;
  for (int i = 1; i < (1 << 17); i++) {
    if (meb[i] == 0) continue;
    modint score = calc(memo[i]);
    ans += (modint)meb[i] * score;
  }
  cout << ans << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init();
  solve();
  return 0;
}