#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n, nr[100002], ans[100002], x, y;
long long logpow(long long a, long long b) {
  if (b < 0) return 0;
  long long p = 1;
  while (b) {
    if (b & 1) p = 1ll * p * a % mod;
    b >>= 1;
    a = 1ll * a * a % mod;
  }
  return p;
}
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x >> y;
    nr[x] += y;
  }
  for (long long i = 100000; i >= 1; i--) {
    long long sq = 0, sum = 0, fr = 0;
    for (long long j = i; j <= 100000; j += i) {
      sq += 1ll * nr[j] % mod * j % mod * j % mod;
      sq %= mod;
      sum += nr[j] * j % mod;
      sum %= mod;
      fr += nr[j];
    }
    sq %= mod;
    sum = 1ll * sum * sum % mod;
    long long x = (sum - sq + mod) % mod;
    ans[i] =
        sq * logpow(2, fr - 2) % mod * ((fr - 1) % mod) +
        x * (logpow(2, fr - 3) * ((fr - 2) % mod) % mod + logpow(2, fr - 2)) %
            mod;
    ans[i] %= mod;
    for (long long j = 2 * i; j <= 100000; j += i)
      ans[i] = (ans[i] - ans[j] + mod) % mod;
  }
  cout << ans[1];
  return 0;
}
