#include using namespace std; int n,z,i;char y; main(){ cin>>n; deque A; while(cin>>z>>y){if(z)A.push_front(y);else A.push_back(y);} while(n--){cout<