Problem: 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.

Solution (in JAVA):

Solution:
/**
 * author: derrick20
 * created: 11/8/20 5:17 PM
 */
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class SumOverSubsets {
    public static void main(String[] args) {
        int MAX = (int) 1e5;
        ArrayList<Integer>[] divisors = new ArrayList[MAX + 1];
        Arrays.setAll(divisors, i -> new ArrayList<>());
        for (int div = 1; div <= MAX; div++) {
            for (int multiple = div; multiple <= MAX; multiple += div) {
                divisors[multiple].add(div);
            }
        }
        int[] mobius = new int[MAX + 1];
        mobius[1] = 1;
        for (int v = 2; v <= MAX; v++) {
            for (int div : divisors[v]) {
                if (div != v) {
                    mobius[v] -= mobius[div];
                }
            }
        }
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        long[][] vals = new long[N][2];
        for (int i = 0; i < N; i++) {
            long val = sc.nextLong();
            long freq = sc.nextLong();
            vals[i] = new long[]{val, freq};
        }
        long[] S0 = new long[MAX + 1];
        long[] S1 = new long[MAX + 1];
        long[] S2 = new long[MAX + 1];
        for (long[] e : vals) {
            long val = e[0];
            long freq = e[1];
            long contrib0 = freq;
            long contrib1 = mult(val, freq);
            long contrib2 = mult(mult(val, val), freq);
            for (int div : divisors[(int) val]) {
                S0[div] += contrib0; // KEY BUG IT'S AN EXPONENT!
                S1[div] = add(S1[div], contrib1);
                S2[div] = add(S2[div], contrib2);
            }
        }
        long[] contrib = new long[MAX + 1];
        // store for each gcd g, the contribution for all multisets with gcd = kg
        long ans = 0;
        for (int g = 1; g <= MAX; g++) {
            long n = S0[g];
            if (n <= 1) continue;
            else {
                long squaresCoeff = mult((n - 1) % mod, fastExpo(2, n - 2));
                long squares = mult(squaresCoeff, S2[g]);
                contrib[g] = squares;
                long crossCoeff = n == 2 ? 1 : mult(n % mod, fastExpo(2, n - 3));
                long cross = mult(crossCoeff, sub(mult(S1[g], S1[g]), S2[g]));
                contrib[g] = add(contrib[g], cross);
            }
            ans = add(ans, mult(mobius[g], contrib[g]));
        }
        out.println(ans);
        out.close();
    }

    static long mod = 998244353;

    static long add(long a, long b) {
        long ans = (a + b) % mod;
        if (ans < 0) ans += mod;
        return ans;
    }

    static long sub(long a, long b) {
        long ans = (a - b) % mod;
        if (ans < 0) ans += mod;
        return ans;
    }

    static long mult(long a, long b) {
        long ans = (a * b) % mod;
        if (ans < 0) ans += mod;
        return ans;
    }

    static long fastExpo(long x, long k) {
        long ans = 1;
        k %= mod - 1;
        while (k > 0) {
            if ((k & 1) > 0) {
                ans = (ans * x) % mod;
            }
            x = (x * x) % mod;
            k >>= 1;
        }
        return ans;
    }

    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }
    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }
    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}