QOJ.ac

QOJ

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

#7435. Gödel Machine

الإحصائيات

Since you cannot design a Gödel machine, you decide to solve a data structure problem first:

Given a sequence $a_1, \dots, a_n$ of length $n$. You need to answer $m$ queries. The $i$-th query provides an interval $[l_i, r_i]$. Please calculate the product of the greatest common divisors (GCDs) of all non-empty subsets of this interval. Since the answer can be very large, output the result modulo $998244353$ for each query.

Input

The first line contains two positive integers $n$ and $m$, as described above.

The next line contains $n$ positive integers describing the sequence $a_1, \dots, a_n$.

The next $m$ lines each contain $l_i$ and $r_i$, describing the $i$-th query.

Output

Output $m$ lines, each containing the result of the query modulo $998244353$.

Examples

Input 1

5 3
2 6 3 15 5
4 4
1 3
2 5

Output 1

15
216
546750

Input 2

6 6
3332 411 6666 6291 415 7180
4 6
1 5
5 6
4 4
1 2
1 3

Output 2

889738671
989336054
14898500
6291
1369452
867407130

Subtasks

Idea: ouuan&lk, Solution: ccz181078, Code: ouuan&lk, Data: ouuan&lk

For $10\%$ of the data, $n, m \le 10$.

For another $10\%$ of the data, $n, m \le 1000$.

For another $20\%$ of the data, $1 \le a_i \le 1000$.

For another $10\%$ of the data, for all $1 \le i < n$, $l_i \le l_{i+1} \le 10^5$ and $r_i \le r_{i+1} \le 10^5$.

For another $20\%$ of the data, $1 \le a_i \le 30000$.

For $100\%$ of the data, $1 \le n, m, a_i \le 10^5$ and $1 \le l_i \le r_i \le n$.

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.