import datetime n=int(input()) for i in range(n): y=int(input()) m=5 d=1 w=datetime.date(y,m,d).weekday() if w==0: print 9 elif w==1 or w==6: print 6 else: print 5