#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int lint; #define rep(i, n) for (lint i = 0; i < n; i++) #define sort(v) sort((v).begin(), (v).end()) #define reverse(v) reverse((v).begin(), (v).end()) #define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge) #define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge) #define mp make_pair #define IP pair #define enld endl int main() { lint N; cin >> N; vectorT(N); vectorS(N); rep(i, N) { cin >> T[i] >> S[i]; } dequeQ; rep(i, N) { if (T[i] == 0) { Q.push_back(S[i]); } else { Q.push_front(S[i]); } } rep(i, N) { cout << Q[i]; } cout << enld; }