File standardInput readLines map(split map(asNumber)do(writeln((pop-(y:=if(3>m:=pop,m=m+12;-1,0)+pop)%4*2+y%100*4-y%400%7+(2.6*m+1.6|0))%7)))