f = [6,9,6,5,5,5,5] tcase = int(raw_input().strip()) for case in range(tcase): n = int(raw_input().strip()) j = 2; for i in range(1929,n+1): if (i%4==0 and i%100!=0)or(i%400==0): j = (j+2)%7 else: j = (j+1)%7 print f[j];