Divisor queries

1

1 votes
Hiring, Open, Recruit, Approved, Hiring, Open, Recruit, Approved, Medium, Hiring, Ternary Search, Number Theory, Data Structures, Algorithms, Mathematics, Searching
Problem

Consider the following function:

= Number of divisors of integer X

You are given an array that consists of integers. You are also provided  queries. There can be only one type of query, . You are required to determine the product of all the numbers in the range from to . The output can contain the values of and . Your task is to print the result of function mod for that product.

Input format

  • First line: Two integers and denoting the number of array elements and the number of queries
  • Next line: numbers denoting the elements of the array
  • Next lines: Two integers and for which the query must be answered

Output format

For each query, you are required to print a single number denoting the answer to that query mod .

Constraints

Note: Each element of the array cannot contain a value that is greater than .

Sample Input
6 2
1 2 3 4 5 6
1 2 
1 6
Sample Output
2
30
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For the 1st query, the product is 2 , F(2)=2. For the second query , product=720 , F(720)=30.

Editor Image

?