import datetime t=int(input()) dec={0:9,1:6,2:5,3:5,4:5,5:5,6:6} while t>0: t=t-1 y=int(input()) m=5 d=1 wd=int(datetime.datetime(y,m,d).weekday()) print(dec[wd])