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