
#include<bits/stdc++.h>
#define li long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define rev(a) reverse(all(a))
#define sort(a) sort(all(a))
#define pb push_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define vli vector<li>
using namespace std;
 
 
template <class T> void read(T& x){
  cin>>x;
}
 
template <class T, class... U> void read1(T& x, U&... u){
  read(x);
  read(u...);
}
 
template <class A> void read1(vector<A>& v){
  for(auto &it:v)
    read(it);
}
 




void solve()
{
    li n;
    cin>>n;

    vli v(n);
    read1(v);

    li gcd1 = 0;
    gcd1 = v[0];
    rep(i,0,n){
      if(i+2 <= n-1){
        gcd1 = __gcd(gcd1,v[i+2]);
      }
      i+=1;
    }

    li gcd2 = 0;
    if(n>1)
    gcd2 = v[1];
    rep(i,1,n){
      if(i+2 <= n-1){
        gcd2 = __gcd(gcd2,v[i+2]);
      }
      i+=1;
    }


    
    if(gcd1==gcd2){
      cout<<0<<endl;
    }
    else{
      bool t1 = false, t2 = false, t3 = false;

      rep(i,0,n){
        if(i%2==0 and v[i]%gcd1==0 ){
          t1 = true;
        }
        if(i%2 and v[i]%gcd1==0){
          t2 = true;
        }
      }

      if(t2 and t1)
        t3 = true;
      else if(gcd1>1){
        cout<<gcd1<<endl;
        return;
      }

      t1 = false,t2 = false;
      rep(i,0,n){
        if(i%2==0 and v[i]%gcd2==0 ){
          t1 = true;
        }
        if(i%2 and v[i]%gcd2==0){
          t2 = true;
        }
      }
        
      if(t1 and t3 and t2)
        cout<<0<<endl;
      else if(gcd2>1)
        cout<<gcd2<<endl;

    }
}   

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE
     freopen("inputf.in", "r", stdin);
     freopen("outputf.in", "w", stdout);
    #endif
     

    li tc;
    cin>>tc;
    rep(i,0,tc){ 
      solve();  
    }  

  return 0;
}