import calendar fj = [9,6,5,5,5,5,6] for i in range(int(input())): print(fj[calendar.weekday(int(input()),5,1)])