#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
const long long mod = 998244353;
inline long long qpow(long long x, long long k) {
  if (k < 0) return 0;
  long long res = 1;
  while (k) {
    if (k & 1) res = res * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return res;
}
long long n, a[100010], fre[100010], siz[100010], ans[100010], g[100010];
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read(), fre[a[i]] = read();
  }
  for (long long i = 1; i <= 100000; i++) {
    long long sum = 0, t1 = 0, t2 = 0;
    for (long long j = 1; i * j <= 100000; j++)
      siz[i] = siz[i] + fre[i * j],
      sum = (sum + fre[i * j] * i * j % mod) % mod;
    for (long long j = 1; i * j <= 100000; j++) {
      if (fre[i * j]) {
        t1 = (t1 + i * j * i * j % mod * fre[i * j] % mod) % mod;
        t2 = (t2 + fre[i * j] * i * j % mod * (sum - i * j + mod) % mod) % mod;
      }
    }
    ans[i] =
        (ans[i] + t1 * qpow(2, siz[i] - 2) % mod * ((siz[i] - 1) % mod) % mod) %
        mod;
    ans[i] = (ans[i] + t2 *
                           ((qpow(2, siz[i] - 3) * ((siz[i] - 2) % mod) % mod +
                             qpow(2, siz[i] - 2)) %
                            mod) %
                           mod) %
             mod;
  }
  for (long long i = 100000; i >= 1; i--)
    for (long long j = 2; i * j <= 100000; j++)
      ans[i] = (ans[i] - ans[i * j] + mod) % mod;
  printf("%lld\n", ans[1]);
  return 0;
}
