let line=readline().split(' ') let len=line.shift(), head=line.shift(), tar=line.pop(); let ans=[head],i=0; while(i<line.length){ let t =line[i+1],n=line[i]; let index=ans.indexOf(t) ans.splice(index+1,0,n) i+=2 } let tarIndex=ans.indexOf(tar) ans.splice(tarIndex,1) console.log(ans.join(' '))