import datetime def printdays(day,days_dict = {0:6,1:9,2:6,3:5,4:5,5:5,6:5}): print days_dict[day] n=int(raw_input()) for i in range(n): year=int(raw_input()) anyday=datetime.datetime(year,05,01).strftime("%w") printdays(int(anyday))