#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
int N = 100000;
long long frep[101010];
int mu[101010];
long long qpow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    frep[a] = b;
  }
  mu[1] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = i * 2; j <= N; j += i) mu[j] -= mu[i];
  }
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    long long s = 0, sq = 0;
    long long K = 0;
    for (int j = i; j <= N; j += i) {
      K += frep[j];
      s = (s + frep[j] * j) % mod;
      sq = (sq + frep[j] * j % mod * j) % mod;
    }
    if (K < 2) continue;
    long long t1 = sq * qpow(2, K - 2) % mod * ((K - 1) % mod) % mod;
    long long n2 = (s * s + mod - sq) % mod;
    long long t2 = qpow(2, K - 2);
    if (K >= 3) t2 = (t2 + ((K - 2) % mod) * qpow(2, K - 3)) % mod;
    t2 = t2 * n2 % mod;
    ans = (ans + ((t1 + t2) % mod * mu[i] + mod)) % mod;
  }
  printf("%lld", ans);
  return 0;
}
