#!/usr/bin/python import calendar a=int(input()) for i in range(a): year=input() d=calendar.weekday(year,5,1) if d==0: print 9 elif d==1 or d==6: print 6 else: print 5