#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long max_n = 1e5 + 3, mod = 998244353;
long long sum(long long a, long long b) {
  long long r = a + b;
  if (r >= mod) r -= mod;
  if (r < 0) r += mod;
  return (r % mod + mod) % mod;
}
long long mul(long long a, long long b) { return (a * b % mod + mod) % mod; }
long long mul(vector<long long> a) {
  long long r = 1;
  for (long long i : a) r = r % mod * i % mod;
  return (r + mod) % mod;
}
long long binpow(long long a, long long b) {
  if (b < 0) b += mod - 1;
  long long res = 1;
  for (; b; b /= 2, a = mul(a, a))
    if (b & 1) res = mul(res, a);
  return res;
}
void run() {
  long long n;
  cin >> n;
  vector<long long> f(max_n);
  for (long long i = 0; i < n; ++i) {
    long long v, x;
    cin >> v >> x;
    f[v] = x;
  }
  vector<long long> dp(max_n);
  for (long long k = 1e5; k >= 1; --k) {
    long long cnt = 0, sm = 0, sm2 = 0;
    bool lone = true;
    for (long long i = 0; i < max_n; i += k) {
      if (cnt != 0 && f[i] != 0) lone = false;
      cnt += f[i];
      sm = sum(sm, mul(f[i] % mod, i));
      sm2 = sum(sm2, mul({f[i] % mod, i, i}));
    }
    long long c = cnt % (mod - 1);
    cnt %= mod;
    if (!lone || cnt != 1) {
      dp[k] = sum(mul({sm % mod, sm % mod,
                       sum(mul(cnt - 2, binpow(2, c - 3)), binpow(2, c - 2))}),
                  mul({sm2, cnt - 2, binpow(2, c - 3)}));
    }
    for (long long i = 2 * k; i < max_n; i += k)
      dp[k] = sum(dp[k], mod - dp[i]);
  }
  cout << dp[1] % mod << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  run();
}
