Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that 
GCD of all integers in that subarray is 1.

Formally,
For a subarray Ai,Ai+1...Aj where 1 ≤ i < j ≤ N to be valid: GCD(Ai,Ai+1...Aj) should be 1. You have to print the size of the largest valid subarray.
If no valid subarray exists, output -1.
Note:A single element is not considered as a subarray according to the definition of this problem.

-----Input-----
First line contains T, the number of testcases. Each testcase consists of N in one line followed by N integers in the next line.

-----Output-----
For each testcase, print the required answer in one line.

-----Constraints-----
- 1 ≤ T ≤ 10
- 2 ≤ N ≤ 105
- 1 ≤ Ai ≤ 105

-----Example-----
Input:
2
2
7 2
3
2 2 4

Output:
2
-1

-----Explanation-----
Example case 1.GCD(2,7)=1. So the subarray [A1,A2] is valid.
Example case 2.No subarray satisfies.
Note: Use scanf/print instead of cin/cout. Large input files.

Difficulty: MEDIUM_HARD

Solutions:
def gcd(a, k):
	while a:
		k %= a
		(k, a) = (a, k)
	return k
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a[0] < a[1]:
		k = a[0]
	else:
		k = a[1]
	for l in a:
		k = gcd(k, l)
	if k == 1:
		print(n)
	else:
		print(-1)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = l[0]
	for i in range(1, n):
		a = gcd(l[i], a)
	if a == 1:
		print(n)
	else:
		print(-1)


from math import gcd
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = a[0]
	for i in range(1, n):
		b = gcd(b, a[i])
		if b == 1:
			print(n)
			break
	else:
		print(-1)


def gcd(a, b):
	if b > a:
		return gcd(b, a)
	elif b == 0:
		return a
	else:
		return gcd(b, a % b)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	val = arr[0]
	for i in range(1, n):
		val = gcd(val, arr[i])
	if val == 1:
		print(n)
	else:
		print(-1)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	g = arr[0]
	for i in arr:
		g = gcd(g, i)
	if g == 1:
		print(n)
	else:
		print(-1)
	t -= 1


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = l[0]
	for j in range(1, n):
		a = math.gcd(l[j], a)
	if a == 1:
		print(n)
	else:
		print(-1)


from math import gcd
for _ in range(int(input())):
	N = int(input())
	lst = list(map(int, input().split()))
	ans = lst[0]
	for i in range(1, N):
		ans = gcd(ans, lst[i])
	if ans == 1:
		print(N)
	else:
		print(-1)


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	num1 = l[0]
	num2 = l[1]
	gcd = find_gcd(num1, num2)
	for i in range(2, len(l)):
		gcd = find_gcd(gcd, l[i])
	if gcd == 1:
		print(len(l))
	else:
		print(-1)


gcd = lambda a, b: a if b == 0 else gcd(b, a % b)
for _ in range(int(input())):
	(_, a) = (input(), list(map(int, input().split())))
	(g, m) = (0, -1)
	for (i, x) in enumerate(a):
		g = gcd(g, x)
		if g == 1 and i + 1 > m and (i != 0):
			m = i + 1
	print(m)


import math
t = int(input())
while t != 0:
	n = int(input())
	lst = list(map(int, input().split()))
	mem = lst[0]
	for i in range(1, len(lst)):
		mem = math.gcd(lst[i], mem)
	if mem == 1:
		print(n)
	else:
		print('-1')
	t -= 1


import math as b
t = int(input())
for i in range(t):
	n = int(input())
	c = 0
	l = list(map(int, input().split()))
	p = len(l)
	m = l[0]
	for j in range(1, p):
		m = b.gcd(l[j], m)
	if m == 1:
		print(n)
	else:
		print(-1)


import math
t = int(input())
while t > 0:
	n = int(input())
	array = list(map(int, input().split()))
	gcd = array[0]
	for i in range(n):
		gcd = math.gcd(gcd, array[i])
		if gcd == 1:
			break
	if gcd == 1:
		print(n)
	else:
		print(-1)
	t -= 1


import math
t = int(input())
for z in range(t):
	flag = 0
	n = int(input())
	a = list(map(int, input().split()))
	result = a[0]
	for i in range(1, n):
		result = math.gcd(result, a[i])
	if result == 1:
		print(n)
	else:
		print(-1)


import math

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
t = int(input())
for i in range(0, t):
	k = int(input())
	a = list(map(int, input().split()))
	c = a[0]
	for j in range(1, len(a)):
		c = gcd(c, a[j])
	if c == 1:
		print(k)
	else:
		print(-1)


from math import gcd
for _ in range(int(input())):
	N = int(input())
	L = list(map(int, input().split()))
	g = gcd(L[0], L[1])
	for i in range(2, N):
		if g == 1:
			break
		g = gcd(g, L[i])
	print(N if g == 1 else -1)


from sys import stdin, stdout
import math
from collections import Counter
import functools
import time
import bisect

def tr():
	return range(int(line()))

def sm():
	return map(int, line().split())

def ln():
	return list(sm())

def nl():
	return int(line())

def ssm():
	return map(str, line().split())

def line():
	return stdin.readline().rstrip()

def b(x):
	return bin(x).replace('0b', '')

def o(x):
	if type(x) != type(''):
		x = str(x)
	stdout.write(x + '\n')

def osp(x):
	if type(x) != type(''):
		x = str(x)
	stdout.write(x + ' ')

def ol(x):
	stdout.write(' '.join(map(str, x)))

def wline():
	return stdin.read().split()

def gcd_of_list(arr):
	gcd = arr[0]
	for i in arr:
		gcd = math.gcd(gcd, i)
	return gcd

def main():
	for _ in tr():
		n = nl()
		a = ln()
		if gcd_of_list(a) == 1:
			print(n)
		else:
			print(-1)
main()


import sys
from os import path
if path.exists('Input.txt'):
	sys.stdin = open('Input.txt', 'r')
	sys.stdout = open('Output.txt', 'w')
from math import gcd, floor, sqrt, log, ceil
import math
from collections import deque
read = lambda : int(input())
li = lambda : list(map(int, input().split()))
read2 = lambda : map(int, input().split())
M = 1000000007
(yes, no) = ('YES', 'NO')

def fact(n):
	return math.factorial(n)

def isPrime(n):
	if n % 2 == 0 and n != 2 or n < 2:
		return False
	i = 3
	while i * i <= n:
		if n % i == 0:
			return False
		i += 2
	return True

def solve():
	n = read()
	a = li()
	ans = a[0]
	for i in range(1, n):
		ans = gcd(ans, a[i])
	if ans == 1:
		print(n)
	else:
		print(-1)
for _ in range(int(input())):
	solve()


from math import gcd
for t in range(int(input())):
	n = int(input())
	a = sorted(set((int(i) for i in input().split())))
	l = len(a)
	for j in range(l - 1):
		if gcd(a[j], a[j + 1]) == 1:
			print(n)
			break
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	m = min(l)
	f = 0
	for j in range(2, m + 1):
		c = 0
		for k in l:
			if k % j == 0:
				c = c + 1
			else:
				break
		if c == len(l):
			f = 1
			break
	if f:
		print(-1)
	else:
		print(n)


import math
for _ in range(int(input())):
	n = int(input())
	li1 = list(map(int, input().split()))
	g1 = math.gcd(li1[0], li1[1])
	for i in range(2, n):
		g1 = math.gcd(g1, li1[i])
	if g1 == 1:
		print(n)
	else:
		print('-1')


from math import *
for i in range(int(input())):
	num = int(input())
	list1 = list(map(int, input().split()))
	x = list1[0]
	for a in range(1, num):
		x = gcd(x, list1[a])
	if x == 1:
		print(num)
	else:
		print(-1)


import math
for _ in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	x = math.gcd(arr[0], arr[1])
	for element in arr[2:]:
		x = math.gcd(x, element)
	if x == 1:
		print(N)
	else:
		print(-1)


def compute_hcf(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	gcd = a[0]
	for i in range(len(a)):
		gcd = compute_hcf(gcd, a[i])
		if gcd == 1:
			break
	if gcd == 1:
		print(n)
	else:
		print(-1)


import math
for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = l[0]
	z = 0
	for i in range(1, len(l)):
		ans = math.gcd(l[i], ans)
		if ans == 1:
			z = i + 1
		else:
			continue
	if z > 1:
		print(z)
	else:
		print(-1)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	gcdd = arr[0]
	for i in arr:
		gcdd = gcd(gcdd, i)
	print(len(arr)) if gcdd == 1 else print(-1)


from math import gcd

def largestgcd():
	n = int(input())
	ls = list(map(int, input().split()))
	gc = 0
	f = 0
	for i in range(n):
		gc = gcd(gc, ls[i])
		if gc == 1:
			f = 1
			break
	if f == 1:
		print(n)
	else:
		print(-1)

def __starting_point():
	for _ in range(int(input())):
		largestgcd()
__starting_point()


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
for _ in range(int(input())):
	n = int(input())
	li = [int(x) for x in input().strip().split()]
	gc = li[0]
	for i in range(n):
		gc = gcd(gc, li[i])
		if gc == 1:
			break
	if gc == 1:
		print(n)
	else:
		print(-1)


import functools
t = int(input())

def gcdn(s, n):

	def gcd(x, y):
		while y:
			(x, y) = (y, x % y)
		return x
	t = functools.reduce(lambda x, y: gcd(x, y), s)
	if t == 1:
		return n
	else:
		return -1
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	r = gcdn(s, n)
	print(r)


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	flag = False
	gcd = arr[0]
	for i in range(1, len(arr)):
		gcd = find_gcd(gcd, arr[i])
		if gcd == 1:
			flag = True
			break
	if flag:
		print(len(arr))
	else:
		print('-1')


def gcd(x, y):
	if not y:
		return x
	return gcd(y, x % y)
for t in range(int(input())):
	input()
	arr = list(map(int, input().split()))
	s = False
	for i in range(len(arr) - 1):
		temp = gcd(arr[i], arr[i + 1])
		if temp == 1:
			print(len(arr))
			s = True
			break
		else:
			arr[i + 1] = temp
	if not s:
		print(-1)


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = math.gcd(l[0], l[1])
	for i in l[2:]:
		x = math.gcd(x, i)
	print(n if x == 1 else -1)


try:

	def is_valid(x, y, d):
		q = str(x) + ',' + str(y)
		if q in d:
			return d[q]
		if y == 0:
			d[q] = x
			return x
		else:
			d[q] = is_valid(y, x % y, d)
			return d[q]
	T = int(input())
	for ijkl in range(0, T):
		n = int(input())
		a = list(map(int, input().split()))
		d = {}
		gcd = is_valid(a[0], a[1], d)
		for i in a[2:]:
			gcd = is_valid(gcd, i, d)
		if gcd == 1:
			print(n)
		else:
			print(-1)
except:
	pass


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for i in range(t):
	n = int(input())
	c = 0
	l = list(map(int, input().split()))
	p = len(l)
	m = l[0]
	for j in range(1, p):
		if gcd(l[j], m) == 1:
			c += 1
	if c >= 1:
		print(n)
	else:
		print(-1)