import System.IO;main=mapM(`hSetEncoding`utf8)[stdin,stdout]>>interact(f.span('$'/=));f(b,_:_:r)=lines r?[]where(x:y)?('@':_:z)=x++y?z;x?(y:z)=y:x?z;("1":y)?_=y?b;_?z=z