import datetime
dic1={0:9,1:6,2:5,3:5,4:5,5:5,6:6}
#dic2={0:"一",1:"二",2:"三",3:"四",4:"五",5:"六",6:"日"}
t=int(input())
while t>0:
t=t-1
y=int(input())
# print(dic2[datetime.datetime(y,5,1).weekday()])
print(dic1[datetime.datetime(y,5,1).weekday()])