#!usr/bin/python #coding=utf-8 import datetime T = input() for i in range(T): y=input() d=datetime.datetime(y,5,1).weekday() if d==6 or d==1: k=6 elif d==0: k=9 else: k=5 print k