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: from bisect import insort,bisect_right,bisect_left
  from sys import stdout, stdin, setrecursionlimit
  from heapq import heappush, heappop, heapify 
  from io import BytesIO, IOBase
  from collections import *
  from itertools import *
  from random import * 
  from string import *
  from queue import *
  from math import *
  from re import *
  from os import *
  
  ####################################---fast-input-output----#########################################
  
  
  class FastIO(IOBase):
      newlines = 0
  
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
  
      def read(self):
          while True:
              b = read(self._fd, max(fstat(self._fd).st_size, 8192))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
  
      def readline(self):
          while self.newlines == 0:
              b = read(self._fd, max(fstat(self._fd).st_size, 8192))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
  
      def flush(self):
          if self.writable:
              write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
  
  
  class IOWrapper(IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
  
  
  stdin, stdout = IOWrapper(stdin), IOWrapper(stdout)
  graph, mod, szzz =  {}, 10**9 + 7, lambda: sorted(zzz())
  def getStr(): return input()
  def getInt(): return int(input())
  def listStr(): return list(input())
  def getStrs(): return input().split()
  def isInt(s): return '0' <= s[0] <= '9'
  def input(): return stdin.readline().strip()
  def zzz(): return [int(i) for i in input().split()]
  def output(answer, end='\n'): stdout.write(str(answer) + end)
  def lcd(xnum1, xnum2): return (xnum1 * xnum2 // gcd(xnum1, xnum2))
  
  
  def getPrimes(N = 10**6):
      SN = int(sqrt(N))
      sieve = [i for i in range(N+1)]
      sieve[1] = 0
      for i in sieve:
          if i > SN:
              break
          if i == 0:
              continue
          for j in range(2*i, N+1, i):
              sieve[j] = 0
      prime = [i for i in range(N+1) if sieve[i] != 0] 
      return prime
  def primeFactor(n,prime=getPrimes()):
      lst = []
      mx=int(sqrt(n))+1
      for i in prime:
          if i>mx:break
          while n%i==0:
              lst.append(i)
              n//=i
      if n>1:
          lst.append(n)
      return lst    
  
  dx = [-1, 1, 0, 0, 1, -1, 1, -1]
  dy = [0, 0, 1, -1, 1, -1, -1, 1]
  daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  
  
  #################################################---Some Rule For Me To Follow---#################################
  """
      --instants of Reading problem continuously try to understand them.
  
      --Try & again try, maybe you're just one statement away!
  
  """
  ##########################################b########---START-CODING---###############################################
  
  
  
  
  num = getInt()
  
  
  
  
  for i in range(num):
      n=getInt()
      arr = zzz()
      one = arr[::2]
      two = arr[1::2]
      pos1 = True
      pos2 = True
      ans1 = one[0]
      ans2 = two[0]
      for i in one:ans1=gcd(ans1,i)
      for i in two:ans2=gcd(ans2,i)
  
      for i in two:
          if i%ans1==0:
              pos1 = False
  
      for i in one:
          if i %ans2==0:
              pos2=False
      if pos1:
          print(ans1)
      elif pos2:
          print(ans2)
      else:
          print(0)
  
      
  
  
  
  
  
  
  
  
  
      
  
  
  
      
  
  
  
  
  