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;
const long long M = 998244353;
long long mul(long long a, long long b) { return (a * b) % M; }
long long boop(long long b, long long p) {
  long long ac = 1;
  while (p) {
    if (p & 1) {
      ac = mul(ac, b);
    }
    b = mul(b, b);
    p >>= 1;
  }
  return ac;
}
long long inv(long long v) { return boop(v, M - 2); }
long long bp(long long b, long long p) {
  if (p < 0) {
    return inv(boop(b, -p));
  }
  return boop(b, p);
}
const long long H = 499122177;
long long calc(const vector<pair<long long, long long> >& w) {
  long long so, s, c;
  long long soa, sa, a;
  soa = sa = a = so = s = 0;
  c = 1;
  for (int i = 0; i < w.size(); i++) {
    long long va = w[i].first;
    long long k = w[i].second;
    long long vs = mul(va, va);
    long long pz = bp(2, k);
    long long pa = mul(pz, H);
    long long pb = mul(pa, H);
    long long pc = mul(pb, H);
    pa = mul(pa, k);
    pb = mul(pb, mul(k, k + 1));
    pc = mul(pc, mul(mul(k, k), k + 3));
    soa = mul(so, pa) + 2 * mul(mul(va, s), pb) + mul(mul(vs, c), pc) +
          mul(soa, pz) + 2 * mul(va, mul(sa, pa)) + mul(vs, mul(a, pb));
    so = mul(so, pz) + 2 * mul(s, mul(va, pa)) + mul(vs, mul(c, pb));
    sa = mul(sa, pz) + mul(va, mul(a, pa)) + mul(s, pa) + mul(va, mul(pb, c));
    s = mul(s, pz) + mul(pa, mul(va, c));
    a = mul(a, pz) + mul(c, pa);
    c = mul(c, pz);
    soa %= M;
    so %= M;
    s %= M;
    sa %= M;
    a %= M;
  }
  long long res = soa - so;
  if (res < 0) {
    res += M;
  }
  return res;
}
const int MN = 100100;
vector<long long> fac[MN];
vector<pair<long long, long long> > wa[MN];
long long res[MN];
void pre() {
  for (long long i = 1; i < MN; i++) {
    for (long long j = 1; j * i < MN; j++) {
      fac[i * j].push_back(i);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  pre();
  while (n--) {
    long long a, b;
    cin >> a >> b;
    for (long long fa : fac[a]) {
      wa[fa].emplace_back(a, b);
    }
  }
  for (int i = 0; i < MN; i++) {
    res[i] = calc(wa[i]);
  }
  for (int i = MN - 1; i >= 0; i--) {
    res[i] = (((res[i] % M) + M) % M);
    for (long long fa : fac[i]) {
      if (fa == i) {
        continue;
      }
      res[fa] -= res[i];
    }
  }
  cout << res[1] << '\n';
}