#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; deque q; rep(_,N) { int t; char c; cin >> t >> c; if(t == 0) q.push_back(c); else q.push_front(c); } for(int i = 0; i < N; i++) cout << q[i]; cout << endl; }