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

#SP0000231. Đếm cách phân tích thừa số nguyên tố (Counting Factorizations)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đếm cách phân tích thừa số nguyên tố (Counting Factorizations)

Counting Factorizations

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Every positive integer mm has a unique prime factorization m=p1e1⋯pkekm=p_1^{e_1}\cdots p_k^{e_k} where p1<⋯<pkp_1<\cdots<p_k are distinct primes and ei≥1e_i\ge1. Define f(m)f(m) as the multiset containing all 2k2k values p1,e1,…,pk,ekp_1,e_1,\ldots,p_k,e_k. Order does not matter, but multiplicities do. The multiset f(1)f(1) is empty.

Given 2n2n positive integers a1,…,a2na_1,\ldots,a_{2n}, count the number of distinct positive integers mm for which f(m)f(m) equals the given multiset. Print the answer modulo 998244353998244353. A value may appear separately as a prime base and as an exponent.

Input

The first line contains nn. The second line contains exactly 2n2n integers a1,a2,…,a2na_1,a_2,\ldots,a_{2n}.

Output

Print the number of distinct positive integers mm whose multiset f(m)f(m) matches the input, modulo 998244353998244353.

Subtasks

  • Subtask 1 (20 points): 1≤n≤51\le n\le5; 1≤ai≤1061\le a_i\le10^6 for every 1≤i≤2n1\le i\le2n.

  • Subtask 2 (30 points): 1≤n≤801\le n\le80; 1≤ai≤1061\le a_i\le10^6 for every 1≤i≤2n1\le i\le2n.

  • Subtask 3 (50 points): 1≤n≤20221\le n\le2022; 1≤ai≤1061\le a_i\le10^6 for every 1≤i≤2n1\le i\le2n.

Examples

Input

2
1 3 2 3

Output

2

Explanation

The input multiset is {1,2,3,3}\{1,2,3,3\} and n=2n=2. There must be two distinct prime bases, necessarily 22 and 33, leaving exponents 11 and 33. Assigning them yields 23⋅31=242^3\cdot3^1=24 or 21⋅33=542^1\cdot3^3=54. Both produce the required multiset, and no other choices exist. The answer is 22.