#include <bits/stdc++.h>   using namespace std;   const long long iinf = 1e9 + 10;   const long long inf = 1ll << 60;   const long long MOD = 998244353;   void GG() {     cout <<  0 n ;     exit(0);   }   const long long maxn = 1e5 + 5;   vector<pair<long long, long long> > here[maxn];   template <long long mod>   struct Modint {     long long val;     Modint(long long _val = 0) { val = _val; }     operator long long() const { return (*this).val; }     Modint operator+(const Modint& o) const {       return val + o.val >= mod ? Modint(val + o.val - mod) : Modint(val + o.val);     }     Modint operator-() const { return val ? Modint(mod - val) : *this; }     Modint operator-(const Modint& o) const {       return val - o.val < 0 ? Modint(val - o.val + mod) : Modint(val - o.val);     }     Modint operator*(const Modint& o) const { return Modint(val * o.val % mod); }     Modint operator+=(const Modint& o) {       *this = (*this) + o;       return *this;     }     Modint operator-=(const Modint& o) {       *this = (*this) - o;       return *this;     }     Modint operator*=(const Modint& o) {       *this = (*this) * o;       return *this;     }     Modint Pow(long long b) const {       Modint tmp(val), ret(1);       while (b) {         if (b & 1) ret *= tmp;         b >>= 1;         tmp *= tmp;       }       return ret;     }     Modint Pow(const Modint& a, long long b) const { return a.Pow(b); }     inline Modint inv() const { return (*this).Pow(mod - 2); }     Modint operator/(const Modint& o) const { return *this * o.inv(); }     bool operator==(const Modint& o) const { return val == o.val; }   };   Modint<MOD> mpow(Modint<MOD> a, long long n, long long mo = MOD) {     Modint<MOD> re = 1;     while (n > 0) {       if (n & 1) re = re * a % mo;       a = a * a % mo;       n >>= 1;     }     return re;   }   Modint<MOD> inv(long long b, long long mo = MOD) {     if (b == 1) return b;     return (mo - mo / b) * inv(mo % b, mo) % mo;   }   const Modint<MOD> i4 = inv(4);   const Modint<MOD> i2 = inv(2);   Modint<MOD> go(long long x) {     ;     Modint<MOD> oth2 = 0;     Modint<MOD> oth1 = 0;     Modint<MOD> oth0 = 1;     Modint<MOD> siga = 0;     long long sigf = 0;     for (pair<long long, long long>& p : here[x]) {       Modint<MOD> a = p.first, first = p.second;       Modint<MOD> mf = mpow(2, first);       oth2 = mf * oth2 +              oth0 * a * a * mf * i4 * first * (first + (Modint<MOD>)1) +              oth1 * (Modint<MOD>)2 * a * mf * i2 * first;       siga += a * first;       sigf += first;       sigf %= (MOD - 1);       Modint<MOD> m2 = mpow(2, sigf);       oth1 = siga * m2 * i2;       oth0 = m2;     }     Modint<MOD> mpowsigf = mpow(2, sigf);     ;     Modint<MOD> re = 0;     for (pair<long long, long long>& p : here[x]) {       Modint<MOD> a = p.first, first = p.second;       Modint<MOD> have1 = siga * mpowsigf * i4 + a * mpowsigf * inv(4);       Modint<MOD> two = a * a * mpowsigf * i2 + oth2 + oth1 * (Modint<MOD>)2 * a -                         (Modint<MOD>)2 * a * have1;       two *= i2;       ;       re += two * first;     };     return re - oth2;   }   long long mob[maxn];   bool np[maxn];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     long long n;     cin >> n;     for (long long i = 0; i < n; ++i) {       long long a, first;       cin >> a >> first;       for (long long j = 1; j <= sqrt(a); ++j) {         if (a % j == 0) {           here[j].push_back({a, first});           if (j * j != a) {             here[a / j].push_back({a, first});           }         }       }     }     fill(mob, mob + maxn - 1, 1);     for (long long i = 2; i < maxn; ++i) {       if (!np[i]) {         mob[i] = -1;         for (long long j = i + i; j < maxn; j += i) {           mob[j] = -mob[j];           np[j] = 1;         }         if (i * i <= maxn)           for (long long j = i * i; j < maxn; j += i * i) {             mob[j] = 0;           }       }     }     long long re = 0;     for (long long i = 0; i < maxn; ++i) {       if (mob[i] && (long long)here[i].size()) {         re += mob[i] * go(i);         re %= MOD;       }     }     cout << (re + MOD) % MOD <<   n ;   }