#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 998244353;
const int N = 100005;
long long pow_mod(long long x, long long n) {
  if (n < 0) return 0;
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
const int wc = 1e5;
int a[N], mu[N];
long long cal(int t) {
  long long sum = 0, res = 0, g = 0;
  for (int i = t; i <= wc; i += t) {
    sum += a[i];
    g += (long long)i * a[i] % mod;
  }
  if (sum <= 1) return 0;
  long long w1 = pow_mod(2, sum - 2), w2 = pow_mod(2, sum - 3);
  long long s1 = (sum - 1) % mod, s2 = (sum - 2) % mod;
  long long z1 = s1 * w1 % mod, z2 = (s2 * w2 + w1) % mod;
  for (int i = t; i <= wc; i += t) {
    res += (long long)i * i % mod * a[i] % mod * z1 % mod;
    res += (long long)i * i % mod * a[i] % mod * (a[i] - 1) % mod * z2 % mod;
    res += (long long)i * a[i] % mod * ((g - (long long)a[i] * i) % mod) % mod *
           z2 % mod;
  }
  res = (res % mod + res) % mod;
  return res;
}
int main() {
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x] = y;
  }
  mu[1] = 1;
  long long ans = 0;
  for (int i = 1; i <= wc; i++) {
    if (mu[i] == 0) continue;
    ans += mu[i] * cal(i);
    for (int j = i + i; j <= wc; j += i) {
      mu[j] -= mu[i];
    }
  }
  ans = (ans % mod + mod) * (mod + 1) / 2 % mod;
  printf("%lld\n", ans);
  return 0;
}
