#include using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; deque s; for (int i = 0; i < n; ++i) { int t; char c; cin >> t >> c; if (t == 0) s.push_back(c); else s.push_front(c); } for (char c : s) { cout << c; } cout << "\n"; return 0; }