b=1 o=" "*50 while 1: for c in raw_input():e=c>" "and(o[::49]+`b`).strip()[0]or c;b+=`b`==e;o=o[1:]+e print o