#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];
  }
  mint inv2 = 4, inv3 = 8;
  inv2 = inv2.inv();
  inv3 = inv3.inv();
  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;
}
