import datetime n=int(raw_input().strip()) for i in range(n): s=0 data=int(raw_input().strip()) day=int(datetime.datetime(data,5,1).strftime("%w")) if day==1: s=9 elif day==2 or day==0: s=6 else: s=5 print s