ryans-agony-1

Ryan  aims  to  be prodigy  in  competitive  coding .  He  loves  problem  solving , and  likes  questions  related  to  number  theory  a  lot .
One  day  ,  he  came  across  this  particular  question  which turned   out  to  be  his  nightmare .

The  question  gives  him  an  array  A[]  of  N  elements .
He  is  now  supposed  to  print  the  least  common  multiple of  all  N  elements.

BUT here is the TWIST . The problem setter changed problem statement at the last moment.    

Now , the question requires to find out the least multiple of LCM of all elements which is a perfect square.  
As the final answer can be large enough , help Ryan in finding answer%( 10^9+7 ) .

Input :-
First line of the input contains number of test cases – T
Every test case will have 2 lines.
First line will contain number of elements of array A[] –N.
Second line will contain N separated integers – A[i].    

Output:-
For each test case print least multiple of LCM of all elements which is perfect square modulo ( 10^9+7 ).

Constraints:

1 ≤ T ≤ 100  

2 ≤ N ≤ 1000  

1 ≤ A[i] ≤ 100000  

Problem setter : Shivam Garg

SAMPLE INPUT
2
3
4 6 8
2
12 15

SAMPLE OUTPUT
144
900

Explanation

In first test case , LCM of 4,6,8 is 24. Now, the least multiple of 24 which is perfect square is 144.
In second test case ,  LCM of 12 and 15 is 60 . Now , the least multiple of 60 which is a perfect square is 900.

Source: hackerearth | Difficulty: EASY


Solutions: