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(2)
#pragma GCC optimize(3)
using namespace std;
const int N = 2e5 + 10;
int n;
const int mod = 998244353;
struct mint {
  long long x;
  mint(long long a = 0) { x = a >= 0 ? a % mod : mod - (-a) % mod; }
  mint(const mint &m) : x(m.x) {}
  mint &operator+=(const mint &a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator+=(const int &a) {
    if ((x += a) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint &a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const int &a) {
    if ((x += mod - a) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint &operator*=(const int &a) {
    (x *= a) %= mod;
    return *this;
  }
  mint operator+(const mint &a) const {
    mint res(*this);
    return res += a;
  }
  mint operator+(const int &a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint &a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator-(const int &a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator-() const {
    mint res(*this);
    return mint(0) - res;
  }
  mint operator*(const mint &a) const {
    mint res(*this);
    return res *= a;
  }
  mint operator*(const int &a) const {
    mint res(*this);
    return res *= a;
  }
  bool operator==(const mint &a) const { return x == a.x; }
  bool operator==(const int &a) const { return x == a; }
  bool operator!=(const mint &a) const { return x != a.x; }
  bool operator!=(const int &a) const { return x != a; }
  operator bool() const { return x > 0; }
  mint pow(long long t) const {
    mint r = 1, a = *this;
    do {
      if (t & 1) r *= a;
      a *= a;
    } while (t >>= 1);
    return r;
  }
  mint pow(mint t) const {
    mint r = 1, a = *this;
    do {
      if (t.x & 1) r *= a;
      a *= a;
    } while (t.x >>= 1);
    return r;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint &a) { return (*this) *= a.inv(); }
  mint &operator/=(const int &a) { return (*this) *= mint(a).inv(); }
  mint operator/(const mint &a) const {
    mint res(*this);
    return res /= a;
  }
  mint operator/(const int &a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &m) {
    cout << m.x;
    return os;
  }
  friend istream &operator>>(istream &is, mint &m) { return is >> m.x; }
};
mint a[N];
mint ans[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x;
    cin >> a[x];
  }
  for (int i = 100000; i >= 1; i--) {
    mint sum = a[i] * i, tot1 = a[i] * (mint)i * i;
    long long ss = a[i].x;
    for (int j = i + i; j <= 100000; j += i) {
      ans[i] -= ans[j], ss += a[j].x, tot1 += a[j] * (mint)j * (mint)j;
      sum += a[j] * (mint)j;
    }
    if (ss < 2) continue;
    mint G1(2), G2(2);
    G1 = G1.pow(ss - 2);
    if (ss >= 3)
      G2 = G2.pow(ss - 3);
    else
      G2 = 0;
    G2 *= ((mint)ss - 2);
    G2 += G1;
    G1 *= ((mint)ss - 1);
    ans[i] += tot1 * G1;
    mint res = 0;
    for (int j = i; j <= 100000; j += i) {
      res += (sum - a[j] * (mint)j) * a[j] * (mint)j * G2;
      res += max((mint)0, a[j] - 1) * (mint)j * (mint)j * a[j] * G2;
    }
    ans[i] += res;
  }
  cout << ans[1] << '\n';
  return 0;
}