import datetime def week(day,date={0:6,1:9,2:6,3:5,4:5,5:5,6:5}): print date[day] x=int(raw_input()) for i in range(x): year=int(raw_input()) weekday=datetime.datetime(year,05,01).strftime('%w') week(int(weekday))