You are given an array a consisting of n positive integers. You have to choose a positive integer d and paint all elements into two colors. All elements which are divisible by d will be painted red, and all other elements will be painted blue.

The coloring is called beautiful if there are no pairs of adjacent elements with the same color in the array. Your task is to find any value of d which yields a beautiful coloring, or report that it is impossible.

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.

The first line of each testcase contains one integer n (2 ≤ n ≤ 100) — the number of elements of the array.

The second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{18}).

Output

For each testcase print a single integer. If there is no such value of d that yields a beautiful coloring, print 0. Otherwise, print any suitable value of d (1 ≤ d ≤ 10^{18}).

Example

Input


5
5
1 2 3 4 5
3
10 5 15
3
100 10 200
10
9 8 2 6 6 2 8 6 5 4
2
1 3


Output


2
0
100
0
3
1
5
6 5 12 5 16
 1
5
3 5 6 11 2

2
 0

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    static long mod = (int)1e9+7;
    static PrintWriter out=new PrintWriter(new BufferedOutputStream(System.out));
    public static void main (String[] args) throws java.lang.Exception
    {
        FastReader sc =new FastReader();

        int t=sc.nextInt();
   
    //   int t=1;
   
        O : while(t-->0)
        {
            int n=sc.nextInt();
            long a[]=sc.readArrayLong(n);
            N : for(int i=0;i<n;i++)
            {
                boolean b[]=new boolean[n];
                // int count=0;
                for(int j=0;j<n;j++)
                {
                    if((long)(a[j]%a[i])==0l)
                    {
                        b[j]=true;
                    }
                    else
                    {
                        b[j]=false;
                    }
                }
                for(int j=0;j<n-1;j++)
                {
                    if(b[j]==b[j+1])
                    {
                        continue N;
                    }
                }
                out.println(a[i]);
                continue O;
            }
            out.println("0");
        }
        out.flush();
    }

static int findfrequencies(int a[],int n)
{
    int count=0;
    for(int i=0;i<a.length;i++)
    {
        if(a[i]==n)
        {
            count++;
        }
    }
    return count;
}

static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(
                new InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() { return Integer.parseInt(next()); }
 
        long nextLong() { return Long.parseLong(next()); }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
       
        float nextFloat()
        {
            return Float.parseFloat(next());
        }
 
        String nextLine()
        {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
       
        int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}

long[] readArrayLong(int n) {
long[] a=new long[n];
for (int i=0; i<n; i++) a[i]=nextLong();
return a;
}

    }
   
    public static int[] radixSort2(int[] a)
{
int n = a.length;
int[] c0 = new int[0x101];
int[] c1 = new int[0x101];
int[] c2 = new int[0x101];
int[] c3 = new int[0x101];
for(int v : a) {
c0[(v&0xff)+1]++;
c1[(v>>>8&0xff)+1]++;
c2[(v>>>16&0xff)+1]++;
c3[(v>>>24^0x80)+1]++;
}
for(int i = 0;i < 0xff;i++) {
c0[i+1] += c0[i];
c1[i+1] += c1[i];
c2[i+1] += c2[i];
c3[i+1] += c3[i];
}
int[] t = new int[n];
for(int v : a)t[c0[v&0xff]++] = v;
for(int v : t)a[c1[v>>>8&0xff]++] = v;
for(int v : a)t[c2[v>>>16&0xff]++] = v;
for(int v : t)a[c3[v>>>24^0x80]++] = v;
return a;
}

static int[] EvenOddArragement(int a[])
{
    ArrayList<Integer> list=new ArrayList<>();
    for(int i=0;i<a.length;i++)
    {
        if(a[i]%2==0)
        {
            list.add(a[i]);
        }
    }
    for(int i=0;i<a.length;i++)
    {
        if(a[i]%2!=0)
        {
            list.add(a[i]);
        }
    }
    for(int i=0;i<a.length;i++)
    {
        a[i]=list.get(i);
    }
    return a;
}
static int gcd(int a, int b) {
    while (b != 0) {
        int t = a;
        a = b;
        b = t % b;
    }
    return a;
}
    static int lcm(int a, int b)
    {
        return (a / gcd(a, b)) * b;
    }
   
    public static HashMap<Integer, Integer> sortByValue(HashMap<Integer, Integer> hm)
    {
        // Create a list from elements of HashMap
        List<Map.Entry<Integer, Integer> > list =
               new LinkedList<Map.Entry<Integer, Integer> >(hm.entrySet());
 
        // Sort the list
        Collections.sort(list, new Comparator<Map.Entry<Integer, Integer> >() {
            public int compare(Map.Entry<Integer, Integer> o1,
                               Map.Entry<Integer, Integer> o2)
            {
                return (o1.getValue()).compareTo(o2.getValue());
            }
        });
         
        // put data from sorted list to hashmap
        HashMap<Integer, Integer> temp = new LinkedHashMap<Integer, Integer>();
        for (Map.Entry<Integer, Integer> aa : list) {
            temp.put(aa.getKey(), aa.getValue());
        }
        return temp;
    }
    static int DigitSum(int n)
    {
        int r=0,sum=0;
        while(n>=0)
        {
            r=n%10;
            sum=sum+r;
            n=n/10;
        }
        return sum;
    }
    static boolean checkPerfectSquare(int number)    
    {   
        double sqrt=Math.sqrt(number);   
        return ((sqrt - Math.floor(sqrt)) == 0);   
    }  
    static boolean isPowerOfTwo(int n)
    {
        if(n==0)
        return false;
 
        return (int)(Math.ceil((Math.log(n) / Math.log(2)))) == (int)(Math.floor(((Math.log(n) / Math.log(2)))));
    }
    static boolean isPrime2(int n) 
    {
        if (n <= 1) 
        {
            return false;
        }
        if (n == 2) 
        {
            return true;
        }
        if (n % 2 == 0) 
        {
            return false;
        }
        for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2) 
        {
            if (n % i == 0)
            {
                return false;
            }
        }
        return true;
    }
    static String minLexRotation(String str)
    {
        int n = str.length();
        String arr[] = new String[n];
        String concat = str + str;
        for(int i=0;i<n;i++)
        {
            arr[i] = concat.substring(i, i + n);
        }
        Arrays.sort(arr);
        return arr[0];
    }
 
static String maxLexRotation(String str)
    {
        int n = str.length();
        String arr[] = new String[n];
        String concat = str + str;
        for (int i = 0; i < n; i++)
        {
            arr[i] = concat.substring(i, i + n);
        }
        Arrays.sort(arr);
        return arr[arr.length-1];
    }
    static class P implements Comparable<P> {
		int i, j;
		public P(int i, int j) {
			this.i=i;
			this.j=j;
		}
		public int compareTo(P o) {
			return Integer.compare(i, o.i);
		}
	}
}