#include #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ALL(x) x.begin(), x.end() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; using ll = long long; using lld = long double; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using PII = pair; random_device rnd; mt19937 mt(rnd()); const int IINF = 1 << 30; const ll INF = 1ll << 60; const ll MOD = 1e9 + 7; int main() { deque que; int n; cin >> n; rep(i, n) { int t; char c; cin >> t >> c; if (t == 0) que.push_back(c); else que.push_front(c); } while (!que.empty()) { cout << que.front(); que.pop_front(); } cout << endl; return 0; }