for(I=i=w="";s=w+(it+=0+readline(e=i)).split(/ |0/)[++I];print(v))for(v=w="";e?--i:s[i++];)v+=s[i-1]||(w+=" ")[0]