LCM^k
Given three integers N,M,K and array of integers a1,a2,...,an.
Find the value of LCM(a1k,a2k,...,ank) mod M, where LCM means Least Common Multiple.
Input
The first line of the input contains a single integer T denoting the number of test cases(1 ≤ T ≤ 10).
The description of T test cases follows.
First line contains three positive integers N, M, K(1 ≤ N ≤ 3 * 105, 1 ≤ M, K ≤ 109).
The second line contains N space-separated integers a1,a2,...,an.(1 ≤ ai ≤ 106,1 ≤ i ≤ N).
Output
For each test case print the value of LCM(a1k,a2k,...,ank) mod M.
In the test LCM(173,23,93,43,123) = 229220928, 229220928 mod 20 = 8.
Note:- Time Extended Problem Occur
Comments
Post a Comment
Please give us your valuable feedback