import time,datetime n=int(input()) dc = {0:9,1:6,2:5,3:5,4:5,5:5,6:6} while n > 0: n=int(input()) t = int(datetime.datetime(n,5,1).weekday()) print dc[t] n = n-1