import calendar for i in range(int(input())): yrs = int(input()) wkd = calendar.weekday(yrs,5,1) if wkd == 0: print(9) elif wkd == 1 or wkd == 6: print(6) else: print(5)