#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; deque q; for (int i = 0; i < n; ++i) { int f; string s; cin >> f >> s; if (f == 0) q.push_back(s); else q.push_front(s); } while (q.size()) { printf("%s", q.front().c_str()); q.pop_front(); } printf("\n"); return 0; }