#-*- coding:UTF-8 -*- import calendar n=int(raw_input()) for i in range(0,n): y=int(raw_input()) s=calendar.weekday(y,5,1) if s==0: print 9 elif s==1 or s==6: print 6 else: print 5