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