import datetime tcase = int(raw_input().strip()) for case in range(tcase): a = int(raw_input()) n = int(datetime.datetime(a,5,1).weekday()) if n == 0: print 9 elif n == 1 or n == 6: print 6 else: print 5