#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 10, mod = 998244353;
int n;
int ans[maxN + 1], s1[maxN + 1], s2[maxN + 1];
long long cnt[maxN + 1];
inline void update(int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; }
inline int mpow(int a, long long x) {
  int ans = 1;
  while (x) {
    if (x & 1) ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
    x >>= 1;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    cnt[x] = y;
    s1[x] = 1ll * x * y % mod;
    s2[x] = 1ll * (1ll * x * x % mod) * y % mod;
  }
  int lim = 1e5;
  for (int i = 1; i <= lim; i++)
    for (int j = i + i; j <= lim; j += i) {
      cnt[i] += cnt[j];
      update(s1[i], s1[j]);
      update(s2[i], s2[j]);
    }
  for (int i = 1; i <= lim; i++) {
    int sa = s2[i], sb = (1ll * s1[i] * s1[i] % mod + mod - s2[i]) % mod;
    long long c = cnt[i];
    if (c > 1) {
      update(ans[i], 1ll * (c - 1) % mod * sa % mod * mpow(2, c - 2) % mod);
      update(ans[i], 1ll * sb * mpow(2, c - 2) % mod);
    }
    if (c > 2)
      update(ans[i], 1ll * (c - 2) % mod * sb % mod * mpow(2, c - 3) % mod);
  }
  for (int i = lim; i >= 1; i--)
    for (int j = i + i; j <= lim; j += i) update(ans[i], mod - ans[j]);
  printf("%d\n", ans[1]);
  return 0;
}
