You are given a multiset S. Over all pairs of subsets A and B, such that:

  * B ⊂ A; 
  * |B| = |A| - 1; 
  * greatest common divisor of all elements in A is equal to one; 



find the sum of ∑_{x ∈ A}{x} ⋅ ∑_{x ∈ B}{x}, modulo 998 244 353.

Input

The first line contains one integer m (1 ≤ m ≤ 10^5): the number of different values in the multiset S.

Each of the next m lines contains two integers a_i, freq_i (1 ≤ a_i ≤ 10^5, 1 ≤ freq_i ≤ 10^9). Element a_i appears in the multiset S freq_i times. All a_i are different.

Output

Print the required sum, modulo 998 244 353.

Examples

Input


2
1 1
2 1


Output


9


Input


4
1 1
2 1
3 1
6 1


Output


1207


Input


1
1 5


Output


560

Note

A multiset is a set where elements are allowed to coincide. |X| is the cardinality of a set X, the number of elements in it.

A ⊂ B: Set A is a subset of a set B.

In the first example B=\{1\}, A=\{1,2\} and B=\{2\}, A=\{1, 2\} have a product equal to 1⋅3 + 2⋅3=9. Other pairs of A and B don't satisfy the given constraints.
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 998244353;
const long long maxn = 1e6 + 107;
const double pi = acos(-1.0);
const double eps = 0.0000000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline void pr2(T x, int k = 64) {
  long long i;
  for (i = 0; i < k; i++) fprintf(stderr, "%d", (x >> i) & 1);
  putchar(' ');
}
template <typename T>
inline void add_(T &A, int B, long long MOD = M) {
  A += B;
  (A >= MOD) && (A -= MOD);
}
template <typename T>
inline void mul_(T &A, long long B, long long MOD = M) {
  A = (A * B) % MOD;
}
template <typename T>
inline void mod_(T &A, long long MOD = M) {
  A %= MOD;
  A += MOD;
  A %= MOD;
}
template <typename T>
inline void max_(T &A, T B) {
  (A < B) && (A = B);
}
template <typename T>
inline void min_(T &A, T B) {
  (A > B) && (A = B);
}
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
inline long long powMM(long long a, long long b, long long mod = M) {
  long long ret = 1;
  for (; b; b >>= 1ll, a = a * a % mod)
    if (b & 1) ret = ret * a % mod;
  return ret;
}
int startTime;
void startTimer() { startTime = clock(); }
void printTimer() {
  fprintf(stderr, "/--- Time: %ld milliseconds ---/\n", clock() - startTime);
}
long long kth[maxn];
long long freq[maxn];
int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    int a, f;
    scanf("%d%d", &a, &f);
    freq[a] += f;
  }
  kth[1] = 1;
  int ans = 0;
  for (i = 1; i <= 100000; i++) {
    long long a1 = 0, a2 = 0;
    long long cnt = 0;
    for (int j = i; j <= 100000; j += i) {
      if (j != i) add_(kth[j], M - kth[i]);
      add_(a1, freq[j] % M * j % M);
      add_(a2, freq[j] % M * j % M * j % M);
      cnt += freq[j];
    }
    if (cnt <= 1) continue;
    long long axy = (a1 * a1 % M - a2 + M) % M;
    long long nowval = 0;
    long long base1 = (cnt - 1) % M * powMM(2, cnt - 2) % M;
    long long base2 = (powMM(2, cnt - 2));
    if (cnt >= 3) base2 += (cnt - 2) % M * powMM(2, cnt - 3) % M;
    add_(nowval, a2 * base1 % M);
    add_(nowval, axy * base2 % M);
    add_(ans, nowval * kth[i] % M);
  }
  printf("%d\n", ans);
}
