import calendar n=int(input()) wli=[9,6,5,5,5,5,6] li=[] i=n while i>0: y=int(input()) w=calendar.weekday(y,5,1) li.append(wli[w]) i-=1 for v in li: print(v)