char z[];m;main(i){for(;gets(z);i*=2)(m=m?m:"2052"[z[1]/4&3])&i&&puts(z);}