HCF-LCM
Difficulty: Hard

**Input Format**

First line contains the number of test cases, $T$. Next $2*T$ lines follow, each containing  total number of elements $N$ in the first line and $N$ spaced positive integers, $a_i$ in the second line.

**Output Format**

Output $T$ lines each line in the format:
	
    H:L
    
where $H$ is the highest common factor of the elements and $L$ is the lcm of the elements modulo 500.

**Constraints**

$1 \le T \le 10^5$

$1 \le N \le 10^6 $

$1 \le a_i \le 10^9$

**Sample Input**

    1
    3
    4 12 20
    
**Sample Output**

	4:60

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    #define rep(i,n) for(int i = 0 ; i < n ; i++)
    #define gi(n) cin >> n
    #define pi(n) cout << n
    #define MAX 111111
    ll a[MAX];

    ll GCD(ll a, ll b) { return (b==0 ? a : GCD (b , a%b) ) ; }
    ll LCM(ll a[],ll n) {
        ll ans = 1, j;
        rep(i,n) {
            if(a[i]!=1) {
                for(j = i + 1 ; j < n ; j++) {
                    a[j]/=GCD(a[i],a[j]);
    //reducing all remaining numbers by thier gcd with current number
                }
                ans = (ans * a[i]) % 500;
            }
        }
        return ans;
    }

    int main() {
        ll t, n, i, g, l;
        cin >> t;
        while (t--) {
            cin >> n;
            for (i=0 ; i<n ; i++) cin >> a[i];
            g = a[0];
            for(i=1 ; i<n ; i++){
                g = GCD (g, a[i]);
            }
            l = LCM (a,n);
            cout << g << ":" << abs(l%500) << endl;
        }
        return 0;
    }