#include<bits/stdc++.h>
using namespace std;

string s = "atcoder";

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

    string a;
    int t,n,i,j;
    cin >> t;
    while(t--)
    {
        cin >> a;
        n = a.length();
        if(a > s) cout << 0 << endl;
        else
        {
            for(i=0;i<n;i++)
            {
                if(a[i]!='a') break;
            }
            if(i==n) cout << -1 << endl;
            else if(a[i]>'t') cout << i-1 << endl;
            else cout << i << endl;
        }

    }
}

#include <iostream>
#include <vector> 

using namespace std;

vector <long long> x;

long long gcd(long long a, long long b) {
	if (a == 0) return b;
	else return gcd(b % a, a);
}

int main() {
	long long primes[15] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 };
	int n;
	cin >> n;
	long long temp;
	long long currmin = 9223372036854775806;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		x.push_back(temp);
	}

	long long y;
	bool can;
	for (long long i = 1; i < (1 << 16); i++) {
		y = 1;
		can = true;
		long long t;
		long long s;
		for (int j = 0; j < 15; j++) {
			t = (long long)1 << j;
			s = i & t;
			if (s != 0) y *= primes[j];
		}

		for (int j = 0; j < n; j++) {
			if (gcd(y, x[j]) == 1) {
				can = false;
				break;
			}
		}

		if (can) currmin = min(currmin, y);
	}

	cout << currmin << endl;

	return 0;
}