import calendar nw = [9,6,5,5,5,5,6] n=int(input()) a=[] while n>0: a.append(int(input())) n-=1 for i in a: print(nw[calendar.weekday((i),5,1)])