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