for(;Q=readline().split(' ');print(R.join(' ')))for(R=[];S=Q.shift();)R=R.concat(S<'N'?Q.splice(0,S[1]):R.slice(-S[1]))
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page