Queries and operations
You are given N coins of different value val, that are arranged in a row. You are given Q queries of the following format
.0 X Y:Compute the sum of all the special coins in interval X, N.
• 1 X Y: Compute the multiplication of all the special coins in interval (X, N).
For each query, the Xth position contains a special coin. Here, a coin is considered a special coin if the distance of its index from the index of any other special coin is evenly divisible by Y. For example, if coin at i = 2 is special and the value of Y is 3, then coin at i=5 ,8 , 11 are also considered as special coins.
Note: Since the answers can be large, print the answer modulus 10^9 + 7.
Input format
• The first line contains T denoting the number of test cases,
• The first line of each test case contains N denoting the number of coins.
• The second line of each test case contains N space-separated integers denoting the value of each coin
• The third line of each test case contains Q denoting the number of queries
• Next Q lines of each test case contain three space-separated integers that contain 0 or 1, X, and Y
Output format
Print the answer for each query in a separate line.
Constraints
1<=T<=10
I<N,Q<= 5 x 10^4
1<=X,Y<=N
1<=val<=10^9
Note: It is advisable to use fast Vo for this problem.
Sample input 1
1 5
23547
4
813
122
015
131
30
<-30
1.0
+20
Copy
Sample output 1
6
12
2
140