import datetime dd={0:9,1:6,2:5,3:5,4:5,5:5,6:6} m=int(input()) for i in range(m): year=int(input()) d=datetime.date(year,5,1).weekday() print (dd[d])