#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 1e5, mod = 998244353;
int cnt[N], prim[N], miu[N], vis[N];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return x;
}
inline int power(int a, int b) {
  int res = 1;
  b = (b % (mod - 1) + (mod - 1)) % (mod - 1);
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) res = 1ll * res * a % mod;
  return res;
}
inline void prework() {
  int cnt = 0;
  miu[1] = 1;
  for (int i = 2; i <= M; i++) {
    if (!vis[i]) prim[++cnt] = i, miu[i] = -1;
    for (int j = 1; j <= cnt && i * prim[j] <= M; j++) {
      vis[i * prim[j]] = 1;
      if (i % prim[j])
        miu[i * prim[j]] = -miu[i];
      else {
        miu[i * prim[j]] = 0;
        break;
      }
    }
  }
}
int main() {
  prework();
  int n, a, b, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) a = read(), b = read(), cnt[a] = b;
  for (int d = 1; d <= M; d++) {
    int res = 0, S = 0, s = 0, sum = 0, fp1, fp2;
    for (int i = d; i <= M; i += d)
      S = (S + cnt[i]) % (mod - 1), s = (s + cnt[i]) % mod;
    fp1 = power(2, S - 2), fp2 = power(2, S - 3), s = (s - 2 + mod) % mod;
    for (int i = d; i <= M; i += d)
      res =
          (res + 1ll * cnt[i] * i % mod * i % mod * (s + 1) % mod * fp1 % mod) %
          mod;
    for (int i = d; i <= M; i += d) sum = (sum + 1ll * i * cnt[i] % mod) % mod;
    for (int i = d; i <= M; i += d)
      res = (res + 1ll * cnt[i] * i % mod * (sum - i + mod) % mod * s % mod *
                       fp2 % mod) %
            mod;
    for (int i = d; i <= M; i += d)
      res = (res + 1ll * cnt[i] * i % mod * (sum - i + mod) % mod * fp1 % mod) %
            mod;
    ans = (1ll * ans + res * miu[d] % mod + mod) % mod;
  }
  printf("%d\n", ans);
  return 0;
}
