n=int(input()) for i in range(n): m=int(input()) if m >= 9: print(2) else: print([-1,1,2,1,1,1,2,1,1][m])