#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;
}
CiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGkgbG9uZyBsb25nIGludAojZGVmaW5lIGxkIGxvbmcgZG91YmxlCiNkZWZpbmUgYWxsKHYpIHYuYmVnaW4oKSx2LmVuZCgpCiNk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lbmRsOwogICAgfQogICAgZWxzZXsKICAgICAgYm9vbCB0MSA9IGZhbHNlLCB0MiA9IGZhbHNlLCB0MyA9IGZhbHNlOwoKICAgICAgcmVwKGksMCxuKXsKICAgICAgICBpZihpJTI9PTAgYW5kIHZbaV0lZ2NkMT09MCApewogICAgICAgICAgdDEgPSB0cnVlOwogICAgICAgIH0KICAgICAgICBpZihpJTIgYW5kIHZbaV0lZ2NkMT09MCl7CiAgICAgICAgICB0MiA9IHRydWU7CiAgICAgICAgfQogICAgICB9CgogICAgICBpZih0MiBhbmQgdDEpCiAgICAgICAgdDMgPSB0cnVlOwogICAgICBlbHNlIGlmKGdjZDE+MSl7CiAgICAgICAgY291dDw8Z2NkMTw8ZW5kbDsKICAgICAgICByZXR1cm47CiAgICAgIH0KCiAgICAgIHQxID0gZmFsc2UsdDIgPSBmYWxzZTsKICAgICAgcmVwKGksMCxuKXsKICAgICAgICBpZihpJTI9PTAgYW5kIHZbaV0lZ2NkMj09MCApewogICAgICAgICAgdDEgPSB0cnVlOwogICAgICAgIH0KICAgICAgICBpZihpJTIgYW5kIHZbaV0lZ2NkMj09MCl7CiAgICAgICAgICB0MiA9IHRydWU7CiAgICAgICAgfQogICAgICB9CiAgICAgICAgCiAgICAgIGlmKHQxIGFuZCB0MyBhbmQgdDIpCiAgICAgICAgY291dDw8MDw8ZW5kbDsKICAgICAgZWxzZSBpZihnY2QyPjEpCiAgICAgICAgY291dDw8Z2NkMjw8ZW5kbDsKCiAgICB9Cn0gICAKCmludCBtYWluKCkKewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKDApOwogICAgY291dC50aWUoMCk7CgogICAgI2lmbmRlZiBPTkxJTkVfSlVER0UKICAgICBmcmVvcGVuKCJpbnB1dGYuaW4iLCAiciIsIHN0ZGluKTsKICAgICBmcmVvcGVuKCJvdXRwdXRmLmluIiwgInciLCBzdGRvdXQpOwogICAgI2VuZGlmCiAgICAgCgogICAgbGkgdGM7CiAgICBjaW4+PnRjOwogICAgcmVwKGksMCx0Yyl7IAogICAgICBzb2x2ZSgpOyAgCiAgICB9ICAKCiAgcmV0dXJuIDA7Cn0=