enum M{M;System z;int i,j,b;{try{for(;b>=0;j=b<45?(i=j+4)*0:j*10+b-48)if((b=z.in.read())<11)z.out.println(1437%i-j);}catch(Exception e){}}}