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