import datetime n=int(raw_input()) j=[9,6,5,5,5,5,6] for i in range(n): x=int(input()) y=datetime.date(x,5,1).weekday() print j[y]