n,_=gets.chop,gets $_[n]&&n=$_[/[^ #{n}]/]while gets $><