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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

public class C {

    public static void main(String[] args) throws IOException {
	    Reader reader = new Reader();
        reader.init(System.in);
        int tc = reader.nextInt();
		
		while (tc-- > 0) {
			int n = reader.nextInt(); 
			
			ArrayList<Long> ip = new ArrayList<Long>();
			
			for(int i = 0; i<n; i++) {
				ip.add(reader.nextLong());
			}
			
			long odd[] = new long[n/2];
			long even[]; 
			
			if(n%2 == 0) even = new long[n/2]; 
			else even = new long[n/2 + 1];
			
			for(int i=0; i<even.length; i++) {
				even[i] = ip.get(i*2);
			}
			
			for(int i=0; i<odd.length; i++) {
				odd[i] = ip.get(i*2 + 1);
			}
			
			// Get the GCD of the even indexed elements. If it is 1, 
			// then even indexed elements can't be painted red. They have to be blue. 
			// So check GCD for odd indexed elements in that case and if there is a answer other than 1 
			// then that is a candidate answer 
			// (verify by going thru the other list and divide each number to confirm that the other list is not divisible by candidate ans)  
			// If that is also 1, then no answer exists and print 0. 
			
			long gcdEven = findGCD(even, even.length);
			long gcdOdd = findGCD(odd, odd.length);
			
			
			if(gcdEven == 1 && gcdOdd == 1) System.out.println("0");
			else {
				// check if odd is okay first. 
				for(int i=0; i<even.length; i++){
					if(even[i]% gcdOdd == 0){
						gcdOdd=0; 
						break;
					}
				}
				
				// then check if even is okay 
				for(int i =0; i<odd.length; i++){
					if(odd[i]% gcdEven == 0){
						gcdEven=0; 
						break;
					}
				}
				if (gcdOdd == 0) System.out.println(String.valueOf(gcdEven));
				else System.out.println(String.valueOf(gcdOdd));
			}
			
		}
    }
	
	static long findGCD(long arr[], int n) {
		long result = 0; 
		for (long element: arr) {
			result = gcd(result, element);
			
			if(result == 1) {
				return 1; 
			}
			
		}
		return result;
	}
	
	static long gcd(long a, long b) {
		if(a==0)
			return b;
		return gcd(b%a, a);
	} 

    
}

/** Class for buffered reading int and double values */
    class Reader {
        static BufferedReader reader;
        static StringTokenizer tokenizer;

        /** call this method to initialize reader for InputStream */
        static void init(InputStream input) {
            reader = new BufferedReader(
                    new InputStreamReader(input) );
            tokenizer = new StringTokenizer("");
        }

        /** get next word */
        static String next() throws IOException {
            while ( ! tokenizer.hasMoreTokens() ) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer(
                        reader.readLine() );
            }
            return tokenizer.nextToken();
        }

        static int nextInt() throws IOException {
            return Integer.parseInt( next() );
        }

        static double nextDouble() throws IOException {
            return Double.parseDouble( next() );
        }
		
		static long nextLong() throws IOException {
            return Long.parseLong( next() );
        }
    }