#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; deque q(n); 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); } for(auto s : q) cout << s; cout << "\n"; return 0; }