F. Please, another Queries on Array?
time limit per test
5.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
You are given an array a1,a2,…,ana1,a2,…,an.
You need to perform qq queries of the following two types:
- "MULTIPLY l r x" — for every ii (l≤i≤rl≤i≤r) multiply aiai by xx.
- "TOTIENT l r" — print φ(∏i=lrai)φ(∏i=lrai) taken modulo 109+7109+7, where φφ denotes Euler's totient function.
The Euler's totient function of a positive integer nn (denoted as φ(n)φ(n)) is the number of integers xx (1≤x≤n1≤x≤n) such that gcd(n,x)=1gcd(n,x)=1.
Input
The first line contains two integers nn and qq (1≤n≤4⋅1051≤n≤4⋅105, 1≤q≤2⋅1051≤q≤2⋅105) — the number of elements in array aa and the number of queries.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤3001≤ai≤300) — the elements of array aa.
Then qq lines follow, describing queries in the format given in the statement.
- "MULTIPLY l r x" (1≤l≤r≤n1≤l≤r≤n, 1≤x≤3001≤x≤300) — denotes a multiplication query.
- "TOTIENT l r" (1≤l≤r≤n1≤l≤r≤n) — denotes a query on the value of Euler's totient functio