$_=($"x$=.$/)x19;$p=435;$q=$$;for$b(<>){$m=(1-2*($z=$q&1))*(1+$=*$|--);$r='$'x$z;$q/=2;pos=$p+=$m,s!\G.!$a!while$b=~s/.$r//and$a=$&}s/ +$//gm;print