description: 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
solution: import java.io.*;
  import java.util.*;
  
  public class test {
  	//	static  BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  		static FastReader in ;
  	    static PrintWriter out ;
  	    static{
  	    	if (System.getProperty("ONLINE_JUDGE") == null) {
              // Try block to check for exceptions
              try {
                  // Sets the Output Stream
                  // to output.txt
                  System.setOut(new PrintStream(new FileOutputStream("output.java")));
                  System.setIn(new FileInputStream("input.java"));
              
              }
    
              // Catch block to handle the exceptions
              catch (Exception e) {
              }
  	    }
  	     in = new FastReader();
            out = new PrintWriter(System.out);
  	    }
  	   
  	public static void  main(String[] args) throws IOException {
  
  	    int t = in.ni();
  	    while (t-- > 0 ){
  	    	int n = in.ni();
  	    	long[] arr = in.readLongArray(null,n);
  	    	long result = 0l;
  	    	long gcd = arr[0];
  	    	for (int i = 0; i < n; i+=2)  gcd = gcd(arr[i],gcd);
  	    	if (gcd != 1){
  	    		boolean k = false;
  	    		for (int i = 1; i < n; i+= 2)
  	    			if (arr[i] % gcd == 0){ k = true; break; }
  	    		if (!k){ out.println(gcd); continue; }
  
  	    	} 
  	    		gcd = arr[1];
  	    		for (int i = 1; i < n; i+=2) gcd = gcd(arr[i], gcd);
  	    		if (gcd != 1){
  	    			boolean k = false;
  	    			for (int i = 0; i < n; i+= 2)
  	    				if (arr[i] % gcd == 0){k = true; break; }
  	    			if (!k){
  	    				out.println(gcd);
  	    			    continue;
  	    			}
  	    		}
  	    			out.println(result);	    		
  		}
          out.flush();
     	}
  	
  	public static void solve(){
  	    
  	}
  	
  	public static int gcd(int a, int b)
  	{  if ( a == 0) return b;
  	    return gcd(b%a, a);
  	}
  	 public static long gcd(long a, long b) {
          if (a == 0)
              return b;
          return gcd(b % a, a);
      }
  	 public static int lcm(int a, int b) {
          return (a / gcd(a, b)) * b;
      }
  	 public static long lcm(long a, long b) {
          return (a / gcd(a, b)) * b;
      }
   
  	public static String reverseString(String input )
  	{  StringBuilder str = new StringBuilder("");
  	   for ( int i = input.length()-1; i >= 0; i-- )
  		    str.append(input.charAt(i));
  		return str.toString();
  	}
  	
  	static class Compare implements Comparator<int[]> { //While primitives can not though
                                                                                             //primitive type arrays can be passed as a generic parameter
  		 public int compare( int[] a, int[] b ){
  			 if ( a[0] > b[0] ) return 2;
  			 else if ( a[0] < b[0] ) return -2;
  			 else return 0;
  		 }
  	 }
  	
  	static ArrayList<Integer> factors(int n)
  	 { ArrayList<Integer> list = new ArrayList<Integer>();
  	  list.add(n);
  	  if ( n != 1) list.add(1);
  	   int sq = (int)Math.sqrt(n);
  	   if ( n%sq == 0 && sq != 1 ) list.add(sq);
  	  for ( int i = 2; i < sq; i++ )
  	      if ( n%i == 0){ list.add(i); list.add(n/i); }
  	  return list;
  	 }
  	
  	static class Pair implements Comparable<Pair>{
  		long a; int b;
  		//LinkedList<Pair> list =  new LinkedList<>();
  
  	public Pair(int a, int b ){
  	this.a = a; this.b = b; }
  	
  	public int compareTo(Pair p){
  		if (this.a > p.a ) return 2;
  		else if (this.a < p.a) return -2;
  		else return 0;
  	}
  }
  		
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
   
          public FastReader()
          {
  			br = new BufferedReader( new InputStreamReader(System.in));
          }
       
         public String next()
          {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  }
                  catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
   
          int ni(){ return Integer.parseInt(next()); }
   
          long nl() { return Long.parseLong(next()); }
   
          double nd() {  return Double.parseDouble(next());  }
  		
  		public int[] readIntArray(int[] arr,int n){
  			if ( arr == null ) arr = new int[n];
  			for ( int i = 0; i < n; i++ ) arr[i] = ni();
  			return arr;
  		}
  		public long[] readLongArray(long[] arr, int n ){
  			if ( arr == null ) arr = new long[n];
  			for ( int i = 0; i < n; i++ ) arr[i] = nl();
  			return arr;
  		}
  
   
         public  String readLine()
          {                                                          // readLine method skips to next line
              String str = "";
              try {
                  str = br.readLine();
              }
              catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
  }