


The first line of input contains a single integer ‘T’, denoting the number of test cases.
The second line of each test case contains ‘N’, denoting the number of elements in the array.
The third line of each test case contains the array elements.
The first and only line of each test case contains a number returned after performing the required operations.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 10^4
0 <= arr[i] <= 2 * 10^3
Time limit: 1 sec
We will traverse the array and calculate the product of every element by traversing the array and multiplying the present element with the previously stored product. Similarly, we calculate the GCD of the numbers by traversing the array and checking GCD with the previous GCD and the present element. Finally, we modular exponential to calculate power.
The steps are as follows: