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.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor