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 Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
template <typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
const long long N = 0;
template <int32_t MOD>
struct mod_field {
  int32_t val;
  mod_field(long long v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = v;
  }
  static int32_t mod_inv(int32_t a, int32_t m = MOD) {
    int32_t g = m, r = a, x = 0, y = 1;
    while (r != 0) {
      int32_t q = g / r;
      g %= r;
      swap(g, r);
      x -= q * y;
      swap(x, y);
    }
    return x < 0 ? x + m : x;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return x % m;
    unsigned x_high = x >> 32, x_low = (unsigned)x;
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  explicit operator long long() const { return val; }
  mod_field &operator+=(const mod_field &other) {
    val += other.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  mod_field &operator-=(const mod_field &other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  mod_field &operator*=(const mod_field &other) {
    val = fast_mod((uint64_t)val * other.val);
    return *this;
  }
  mod_field &operator/=(const mod_field &other) { return *this *= other.inv(); }
  friend mod_field operator+(const mod_field &a, const mod_field &b) {
    return mod_field(a) += b;
  }
  friend mod_field operator-(const mod_field &a, const mod_field &b) {
    return mod_field(a) -= b;
  }
  friend mod_field operator*(const mod_field &a, const mod_field &b) {
    return mod_field(a) *= b;
  }
  friend mod_field operator/(const mod_field &a, const mod_field &b) {
    return mod_field(a) /= b;
  }
  mod_field &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  mod_field &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  mod_field operator++(int32_t) {
    mod_field before = *this;
    ++*this;
    return before;
  }
  mod_field operator--(int32_t) {
    mod_field before = *this;
    --*this;
    return before;
  }
  mod_field operator-() const { return val == 0 ? 0 : MOD - val; }
  bool operator==(const mod_field &other) const { return val == other.val; }
  bool operator!=(const mod_field &other) const { return val != other.val; }
  mod_field inv() const { return mod_inv(val); }
  friend ostream &operator<<(ostream &stream, const mod_field &m) {
    return stream << m.val;
  }
  friend istream &operator>>(istream &stream, mod_field &m) {
    return stream >> m.val;
  }
  mod_field pow(long long p) const {
    assert(p >= 0);
    mod_field a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      a *= a;
      p >>= 1;
    }
    return result;
  }
};
mod_field<MM> ans[100005];
long long f[100005];
void solve() {
  long long m;
  cin >> m;
  for (long long i = 0; i < m; ++i) {
    long long a, freq;
    cin >> a >> freq;
    f[a] += freq;
  }
  for (long long i = 100000; i >= 1; --i) {
    long long tot = 0;
    mod_field<MM> sum = 0, sqsum = 0;
    for (long long j = i; j <= 100000; j += i) {
      tot += f[j];
      sum += f[j] * j;
      sqsum += mod_field<MM>(j).pow(2) * f[j];
    }
    if (tot < 2) {
      ans[i] = 0;
    } else {
      ans[i] += sqsum * mod_field<MM>(2).pow(tot - 2) * (tot - 1);
      ans[i] += (sum * sum - sqsum) *
                (mod_field<MM>(2).pow(tot - 1) +
                 (tot - 2) * mod_field<MM>(2).pow(tot - 2)) /
                2;
    }
    for (long long j = 2 * i; j <= 100000; j += i) {
      ans[i] -= ans[j];
    }
  }
  cout << ans[1];
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}