#P1493D. GCD of an Array

    ID: 2432 Type: RemoteJudge 2000ms 256MiB Tried: 2 Accepted: 1 Difficulty: 7 Uploaded By: Tags>brute forcedata structureshashingimplementationmathnumber theorysortingstwo pointers*2100

GCD of an Array

Description

You are given an array aa of length nn. You are asked to process qq queries of the following format: given integers ii and xx, multiply aia_i by xx.

After processing each query you need to output the greatest common divisor (GCD) of all elements of the array aa.

Since the answer can be too large, you are asked to output it modulo 109+710^9+7.

The first line contains two integers — nn and qq (1n,q21051 \le n, q \le 2 \cdot 10^5).

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai21051 \le a_i \le 2 \cdot 10^5) — the elements of the array aa before the changes.

The next qq lines contain queries in the following format: each line contains two integers ii and xx (1in1 \le i \le n, 1x21051 \le x \le 2 \cdot 10^5).

Print qq lines: after processing each query output the GCD of all elements modulo 109+710^9+7 on a separate line.

Input

The first line contains two integers — nn and qq (1n,q21051 \le n, q \le 2 \cdot 10^5).

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai21051 \le a_i \le 2 \cdot 10^5) — the elements of the array aa before the changes.

The next qq lines contain queries in the following format: each line contains two integers ii and xx (1in1 \le i \le n, 1x21051 \le x \le 2 \cdot 10^5).

Output

Print qq lines: after processing each query output the GCD of all elements modulo 109+710^9+7 on a separate line.

Sample Input 1

4 3
1 6 8 12
1 12
2 3
3 3

Sample Output 1

2
2
6

Note

After the first query the array is [12,6,8,12][12, 6, 8, 12], gcd(12,6,8,12)=2\operatorname{gcd}(12, 6, 8, 12) = 2.

After the second query — [12,18,8,12][12, 18, 8, 12], gcd(12,18,8,12)=2\operatorname{gcd}(12, 18, 8, 12) = 2.

After the third query — [12,18,24,12][12, 18, 24, 12], gcd(12,18,24,12)=6\operatorname{gcd}(12, 18, 24, 12) = 6.

Here the gcd\operatorname{gcd} function denotes the greatest common divisor.