Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
F. Sum Over Subsets

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

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

- $$$B \subset A$$$;
- $$$|B| = |A| - 1$$$;
- greatest common divisor of all elements in $$$A$$$ is equal to one;

find the sum of $$$\sum_{x \in A}{x} \cdot \sum_{x \in B}{x}$$$, modulo $$$998\,244\,353$$$.

Input

The first line contains one integer $$$m$$$ ($$$1 \le m \le 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 \le a_i \le 10^5, 1 \le freq_i \le 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 \subset 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\cdot3 + 2\cdot3=9$$$. Other pairs of $$$A$$$ and $$$B$$$ don't satisfy the given constraints.

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/12/2021 02:05:51 (j2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|