#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int v[100066];
vector<int> prime;
int mu[100066];
void init() {
  int N = 100000;
  for (int i = 2; i <= N; i++) {
    if (!v[i]) {
      mu[i] = 1;
      v[i] = i;
      prime.push_back(i);
    }
    for (auto p : prime) {
      if (p > v[i] || i > N / p) break;
      v[i * p] = p;
      if (i % p == 0)
        mu[i * p] = 0;
      else
        mu[i * p] = -mu[i];
    }
  }
}
long long solve(vector<pair<int, int> > vec) {
  long long sum = 0, all = 0;
  long long all1 = 0;
  for (auto x : vec) {
    sum = (sum + 1ll * x.first * x.second) % mod;
    all = (all + x.second) % mod;
    all1 = (all1 + x.second) % (mod - 1);
  }
  long long pp = powmod(2, all1 - 2 + mod - 1) * ((all - 1 + mod) % mod) % mod;
  long long ret = 0;
  long long two0 = powmod(2, all1 - 3 + mod - 1);
  long long two1 = two0 * 2 % mod;
  long long two2 = two1 * 2 % mod;
  long long qq = two1 + (all - 2 + mod) * two0;
  qq = qq % mod;
  for (auto x : vec) {
    ret += pp * x.first % mod * x.first % mod * x.second % mod;
    ret %= mod;
    long long tmp = (sum + mod - x.first) % mod;
    tmp = 1ll * x.second * x.first % mod * tmp % mod * qq % mod;
    ret = (ret + tmp) % mod;
  }
  return ret;
}
int n;
vector<pair<int, int> > vec, V[100066];
int main() {
  init();
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    vec.push_back(make_pair(x, y));
    for (int j = 1; 1ll * j * j <= x; j++) {
      if (x % j) continue;
      V[j].push_back(make_pair(x, y));
      if (x / j != j) V[x / j].push_back(make_pair(x, y));
    }
  }
  long long ans = solve(vec);
  for (int i = 2; i <= 100000; i++) {
    long long tmp = (-solve(V[i]) * mu[i] + mod) % mod;
    ans = (ans + tmp) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
