import datetime jr=[9,6,5,5,5,5,6] T = int(raw_input().strip()) for case in range(T): x=datetime.date(int(input()),5,1).weekday() print jr[x]