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: //package Codeforces;
  import java.util.*;
  
  import java.io.*;
  public  class template{
  	
  	static class FastScanner {
  		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  		StringTokenizer st = new StringTokenizer("");
  		String next () {
  			while(!st.hasMoreTokens()) {
  				try {
  					st=new StringTokenizer(br.readLine());
  				}catch(IOException e) {
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
  		
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  		
  		int[] readArray(int n) {
  			int a[] = new int[n];
  			for(int i=0;i<n;i++) {
  				a[i] = nextInt();
  			}
  			return a;
  		}
  		
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  	}
  	
  	static class helper{
  		
  		//reverse 1-d Array
  		public static void reverse(int arr[]) {
  			int i = 0;
  			int j = arr.length - 1;
  			while(i<j) {
  				int temp = arr[i];
  				arr[i] = arr[j];
  				arr[j] = temp;
  			}
  		}
  		
  		//gcd of two numbers
  		public static long gcd(long a,long b) {
  			if(b == 0) {
  				return a;
  			}
  			return gcd(b,a%b);
  		}
  		
  		//calculate ncr
  		public static int ncr(int n,int r) {
  			int num = n;
  			int deno = r;
  			int a1 = 1;
  			int a2 = 1;
  			for(int i=0;i<r;i++) {
  				a1 *= num;
  				a2 *= deno;
  				num--;
  				deno--;
  			}
  			int ans = a1/a2;
  			return ans;
  		}
  		
  		//isPalindrome
  		public static boolean isPalindrome(String substring){
  		    char ch[] = substring.toCharArray();
  		    int i = 0;
  		    int j = ch.length-1;
  		    while(i<j){
  		        char temp = ch[i];
  		        ch[i] = ch[j];
  		        ch[j] = temp;
  		        i++;
  		        j--;
  		    }
  		    String rev = String.valueOf(ch);
  		    if(rev.equals(substring)){
  		        return true;
  		    }
  		    else{
  		        return false;
  		    }
  		}
  		
  		//sorting 
  
  		 public static void suffleSort(int[] arr) {
  		        int n = arr.length;
  		        Random rnd = new Random();
  		        for (int i = 0; i < n; ++i) {
  		            int tmp = arr[i];
  		            int randomPos = i + rnd.nextInt(n - i);
  		            arr[i] = arr[randomPos];
  		            arr[randomPos] = tmp;
  		        }
  		        Arrays.sort(arr);
  		  }
  		
  		//isPowerOfTwo
  		public static boolean isPowerOfTwo(long x)
  	    {
  	        /* First x in the below expression is
  	        for the case when x is 0 */
  	        return x != 0 && ((x & (x - 1)) == 0);
  	    }
  		
  		//nextPowerOfTwo
  		public static long nextPowerOfTwo(long n)
  	    {
  	        n--;
  	        n |= n >> 1;
  	        n |= n >> 2;
  	        n |= n >> 4;
  	        n |= n >> 8;
  	        n |= n >> 16;
  	        n++;
  	         
  	        return n;
  	    }
  	}
  	
  	
  	
  	public static void main(String[] args) {
  		  FastScanner sc = new FastScanner();
  		  PrintWriter out = new PrintWriter(System.out);
  		  helper help = new helper();
  		  long test = sc.nextLong();
  		  while(test-->0) {
  			 int n = sc.nextInt();
  			 long arr[] = new long[n];
  			 for(int i =0;i<arr.length;i++) {
  				 arr[i] = sc.nextLong();
  			 }
  			 long even = arr[0];
  			 long odd = arr[1];
  			 for(int i=2;i<arr.length;i++) {
  				 if(i%2 == 0) {
  					 even = help.gcd(even,arr[i]);
  				 }
  				 else {
  					 odd = help.gcd(odd,arr[i]);
  				 }
  			 }
  			 long a[] = new long[arr.length];
  			 if(even == 1 && odd == 1) {
  				 out.println("0");
  			 }
  			 else if(even == 1) {
  				 boolean flag = false;
  				 for(int i=0;i<arr.length;i++) {
  					 a[i] = arr[i]%odd;
  				 }
  				 for(int i=0;i<a.length-1;i++) {
  					 if(a[i] == 0 && a[i+1] == 0) {
  						 out.println("0");
  						 flag = true;
  						 break;
  					 }
  					 else if(a[i] != 0 && a[i+1] != 0) {
  						 out.println("0");
  						 flag = true;
  						 break;
  					 }
  				 }
  				 if(flag == false) {
  					 out.println(odd);
  				 }
  			 }
  			 else if(odd == 1) {
  				 boolean flag = false;
  				 for(int i=0;i<arr.length;i++) {
  					 a[i] = arr[i]%even;
  				 }
  				 for(int i=0;i<a.length-1;i++) {
  					 if(a[i] == 0 && a[i+1] == 0) {
  						 out.println("0");
  						 flag = true;
  						 break;
  					 }
  					 else if(a[i] != 0 && a[i+1] != 0) {
  						 out.println("0");
  						 flag = true;
  						 break;
  					 }
  				 }
  				 if(flag == false) {
  					 out.println(even);
  				 }
  			 }
  			 else {
  				 boolean flag = false;
  				 for(int i=0;i<arr.length;i++) {
  					 a[i] = arr[i]%odd;
  				 }
  				 for(int i=0;i<a.length-1;i++) {
  					 if(a[i] == 0 && a[i+1] == 0) {
  						// out.println("0");
  						 flag = true;
  						 break;
  					 }
  					 else if(a[i] != 0 && a[i+1] != 0) {
  						// out.println("0");
  						 flag = true;
  						 break;
  					 }
  				 }
  				 if(flag == false) {
  					 out.println(odd);
  					 continue;
  				 }
  				 
  				 //for even
  				 boolean flag2 = false;
  				 for(int i=0;i<arr.length;i++) {
  					 a[i] = arr[i]%even;
  				 }
  				 for(int i=0;i<a.length-1;i++) {
  					 if(a[i] == 0 && a[i+1] == 0) {
  						 out.println("0");
  						 flag2 = true;
  						 break;
  					 }
  					 else if(a[i] != 0 && a[i+1] != 0) {
  						 out.println("0");
  						 flag2 = true;
  						 break;
  					 }
  				 }
  				 if(flag2 == false) {
  					 out.println(even);
  				 }
  			 }
  		  }
  		  out.flush();
  	}
  	
  }
  
  
  
  class pair {
  	int value;
  	int index;
  	pair(int value,int index){
  		this.value = value;
  		this.index = index;
  	}
  	public int getValue() {
  		return value;
  	}
  	public void setValue(int value) {
  		this.value = value;
  	}
  	public int getIndex() {
  		return index;
  	}
  	public void setIndex(int index) {
  		this.index = index;
  	}
  }
  