#!usr/bin/python #-*- coding: UTF-8 -*- import datetime; n=int(raw_input()) li=[] jr=[9,6,5,5,5,5,6] for year in range(n): week=datetime.date((input()),5,1).weekday() print jr[week]