#include <bits/stdc++.h>
const int MAX = 1e5, MOD = 998244353, INV8 = 873463809;
int p[MAX], mu[MAX];
int mul(long long x, long long y) { return (x % MOD) * (y % MOD) % MOD; }
int pow(int x, long long y) {
  int res = 1;
  while (y > 0) {
    if (y % 2 == 1) res = mul(res, x);
    x = mul(x, x);
    y /= 2;
  }
  return res;
}
struct {
  long long size = 0, sum = 0, sqr = 0;
  void update(int val, int freq) {
    size += freq;
    sum += mul(val, freq);
    sqr += mul(mul(val, val), freq);
  }
  int val() {
    return mul(mul(pow(2, size), INV8),
               mul(mul(sum, sum), size) + mul(sqr, size - 2));
  }
} dp[MAX];
void preprocess() {
  for (int i = 2; i * i < MAX; ++i)
    if (p[i] == 0)
      for (int j = i; i * j < MAX; ++j) p[i * j] = i;
  mu[1] = 1;
  for (int i = 2; i < MAX; ++i)
    if (p[i] == 0)
      mu[i] = -1;
    else if (i / p[i] % p[i] == 0)
      mu[i] = 0;
    else
      mu[i] = -mu[i / p[i]];
}
int main() {
  preprocess();
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int val, freq;
    scanf("%d%d", &val, &freq);
    for (int i = 1; i * i <= val; ++i)
      if (val % i == 0) {
        dp[i].update(val, freq);
        if (i * i < val) dp[val / i].update(val, freq);
      }
  }
  long long res = 0;
  for (int i = 1; i < MAX; ++i) res += MOD + dp[i].val() * mu[i];
  printf("%lld\n", res % MOD);
}
