short x,y,u;main(w){for(;~scanf("%s%s%s",&x,&y,&u);puts(&x))for(;index(&y,x)?w=x,x=y:x/256-y&31?w=y:0;u=w)y=u;}