QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100

#1642. The Law of Cycles

الإحصائيات

There are $n$ points arranged equidistantly on a circle. We connect every pair of points with a line segment. Please color each point with one of $1 \sim a$ colors and each line segment with one of $1 \sim b$ colors, such that the pattern remains different from the original after any rotation of the circle by an angle that is not a multiple of $2\pi$, or after any reflection across any straight line. Calculate the number of such colorings modulo $998244353$.

The value of $n$ is provided in a special way to ensure you can directly obtain its prime factorization.

Input

The first line contains a positive integer $k$, representing that $n$ can be written as the product of $k$ prime numbers.

The second line contains $k$ prime numbers $p_1, p_2, \dots, p_k$, where $n$ is their product.

The third line contains two positive integers $a$ and $b$, as defined in the problem.

Output

Output a single integer representing the number of colorings modulo $998244353$.

Examples

Input 1

1
3
2 2

Output 1

24

Subtasks

For $40\%$ of the data, $n=3 \sim 42$, with one test case for each value, each worth $1$ point.

For $75\%$ of the data, $n \le 10^{12}$.

For $100\%$ of the data, $p_i \le 10^9$, $3 \le n \le 10^{18}$, $1 \le a, b \le 10^8$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.