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
1
5
6 5 12 5 16
 1
5
3 5 6 11 2

2
 0

import java.io.*;
import java.util.*;

public class Solution {
    static class Reader{
        private final BufferedReader reader;
        private StringTokenizer tokenizer;
        Reader(InputStream input)
        {
            this.reader = new BufferedReader(new InputStreamReader(input));
            this.tokenizer = new StringTokenizer("");
        }
        public String next() throws IOException {
            while(!tokenizer.hasMoreTokens())
            {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }
        public int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        public double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
        public long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for(int i=0;i<n;i++)arr[i]=nextInt();
            return arr;
        }
        public long[] nextLongArr(int n)throws IOException {
            long[] arr = new long[n];
            for(int i=0;i<n;i++)arr[i]=nextLong();
            return arr;
        }
        public char[] nextCharArr(int n) throws IOException {
            char[] arr = new char[n];
            for(int i=0;i<n;i++)arr[i] = next().charAt(0);
            return arr;
        }
    }
    public static void main(String[] args) throws IOException {
        Reader scan = new Reader(System.in);
        StringBuffer sb = new StringBuffer();
        BufferedOutputStream bu = new BufferedOutputStream(System.out);

        int t = scan.nextInt();
        while (t-->0)
        {
            int n = scan.nextInt();
            long[] arr = new long[n];
            long gcdA = 0;
            long gcdB = 0;
            boolean stat = true;
            for(int i=0;i<n;i++)
            {
                long x = scan.nextLong();
                arr[i] = x;
                if(i>0)
                {
                    if(arr[i-1]==arr[i] && stat)stat=false;
                }
                if(i%2==0)
                {
                    if(i==0)gcdA = x;
                    else gcdA = gcd(x, gcdA);
                }
                else {
                    if(i==1)gcdB = x;
                    else gcdB = gcd(x, gcdB);
                }
            }
            long ans = 0;
            if(stat)ans = solve(arr, gcdA, gcdB);
            sb.append(ans+"\n");
        }
        bu.write((sb.toString()).getBytes());
        bu.flush();
    }

    private static long gcd(long x, long y) {
        long max = Math.max(y, x);
        long min = Math.min(y, x);
        if(min == 0)return max;
        return gcd(max%min, min);
    }

    private static long solve(long[] arr, long gcdA, long gcdB) {
        int n = arr.length;
        if(gcdA==gcdB)return 0;
        boolean stat1 = true;
        boolean stat2 = true;
        for(int i=1;i<n;i+=2)
        {
            if(arr[i]%gcdA==0){
                stat1 = false; break;
            }
        }
        for(int i=0;i<n;i+=2)
        {
            if(arr[i]%gcdB==0){
                stat2 = false; break;
            }
        }
        if(stat1)return gcdA;
        else if(stat2)return gcdB;
        return 0;
    }

    private static boolean isPossible(long[] arr, long k, long mid) {
        long damage = 0;
        for(int i=1;i<arr.length;i++)
        {
            damage += Math.min(arr[i] - arr[i - 1], mid);
        }
        damage += mid;
        return damage >= k;
    }


}
class comp implements Comparator<Long> {
    @Override
    public int compare(Long o1, Long o2) {
        return (int)(o1-o2);
    }
}