PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000176. Phân tích số lượng, tổng và tích các ước (Divisor Analysis)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phân tích số lượng, tổng và tích các ước (Divisor Analysis)

Divisor Analysis

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

A positive integer XX can be too large to represent directly. It is therefore provided through its prime factorization:

X=p1e1p2e2⋯pnen,X=p_1^{e_1}p_2^{e_2}\cdots p_n^{e_n},

where all pip_i are distinct primes and all eie_i are positive integers.

Find (1) the number of positive divisors of XX, (2) the sum of its positive divisors, and (3) the product of its positive divisors. For X=12X=12, its divisors are 1,2,3,4,6,121,2,3,4,6,12, giving 66, 2828 and 17281728.

Print the three results modulo 109+710^9+7.

Input

The first line contains nn, the number of distinct prime factors. Each of the next nn lines contains two integers pi,eip_i,e_i; every pip_i is prime and the primes are distinct.

Output

Print three integers on one line: the number, sum and product of divisors, each modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): $1 \le n \le 10,\quad 2 \le p_i \le 100,\quad 1 \le e_i \le 6$.
  • Subtask 2 (30 points): $1 \le n \le 10^3,\quad 2 \le p_i \le 10^5,\quad 1 \le e_i \le 10^6$.
  • Subtask 3 (50 points): $1 \le n \le 10^5,\quad 2 \le p_i \le 10^6,\quad 1 \le e_i \le 10^9$.

Examples

Example 1

Input

2
2 2
3 1

Output

6 28 1728

Explanation

X=22⋅3=12X=2^2\cdot3=12 has divisors 1,2,3,4,6,121,2,3,4,6,12, whose count, sum and product are 66, 2828 and 17281728.