You are given a prime number P.
Let's define V(x) as the degree of P in the prime factorization of x. To be clearer, if V(x)=y then x is divisible by Py, but not divisible by Py+1. Also we define V(0)=0.
For example, when P=3, and x=45, since 45=5⋅32, therefore V(45)=2.
You are also given an array A with N elements. You need to process Q queries of 2 types on this array:
1 pos val - assign a value val to the element at pos, i.e. A_pos:=val2 S L R - print ∑_i=LRV(A_iS−(A_imodP)S).The first line of the input gives the number of test cases, T. T test cases follow.
The first line of each test case contains 3 space separated positive integers N, Q and P - the number of elements in the array, the number of queries and a prime number.
The next line contains N positive integers A_1, A_2, ⋯, A_N representing elements of array A.
Each of the next Q lines describes a query, and contains either
1 pos val2 S L RFor each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is a list of the answers for each query of type 2.
For at most 10 cases:
For the remaining test cases:
There will always be at least one query of type 2.
In Sample Case #1
The first query is a query of type 2, where S=3, L=3, R=4. Let's calculate the result for this query:
i=3, V(623−(62mod2)3)=3
i=4, V(673−(67mod2)3)=1
∑_i=34V(A_i3−(A_imodP)3)=3+1=4
The second query is of type 1, where we need to assign 69 to A_1, so our array A now becomes: 69 94 62 67 91.