// Cheese-Cracker: cheese-cracker.github.io

void solve(){
    auto n = scan;
    auto arr = scanArray;
    long gcd1 = arr[0];
    for(int i = 2; i < n; i += 2){
        gcd1 = gcd(gcd1, arr[i]);
    }
    long gcd2 = arr[1];
    for(int i = 3; i < n; i += 2){
        gcd2 = gcd(gcd2, arr[i]);
    }
    show(gcd1, gcd2);

    bool f = 1;
    for(int i = 1; i < n; i += 2){
        if(arr[i] % gcd1 == 0){
            f = 0;
            break;
        }
    }
    if(f){
        writeln(gcd1);
        return;
    }

    f = 1;
    for(int i = 0; i < n; i += 2){
        if(arr[i] % gcd2 == 0){
            f = 0;
            break;
        }
    }
    if(f){
        writeln(gcd2);
        return;
    }

    writeln(0);
}

void main(){
    long tests = scan;        // Toggle!
    while(tests--) solve;
}

/**************    *****    That's All Folks!    *****    **************/
import std.stdio, std.range, std.conv, std.typecons, std.algorithm, std.container, std.math, std.numeric;
string[] tk; T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");
