import datetime d={"0":6,"1":9,"2":6,"3":5,"4":5,"5":5,"6":5} q=int(input()) i=1 while i<=q: a=int(input()) day=datetime.datetime(a,5,1).strftime("%w") print(d[day]) i+=1