import calendar tcase=int(raw_input()) for i in range(tcase): year=int(raw_input()) n=calendar.weekday(year,5,1) if n==0: print 9 elif n==1 or n==6: print 6 else: print 5