#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; int N, T; char c; deque deq; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> T >> c; if (T == 0) deq.push_back(c); if (T == 1) deq.push_front(c); } for (auto c: deq) { cout << c; } cout << endl; return 0; }