{ll n,z;char y;rd(n);dequeA;rep(n)rd(z,y),if(z)A.push_front(y),else A.push_back(y);rep(n)wtN(A.front()),A.pop_front();}