#include #include #include #include #include #include #include #include #include #include using namespace std; #define next '\n' #define sp " " #define print(x) cout << (x) #define println(x) cout << (x) << next #define stop return(0) #define rep(i, n) for(int (i) = (0); (i) < (n); (++i)) #define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i)) #define foreach(e, elem) for(auto& (e) : (elem)) #define debug(elem) foreach(e, elem){ cout << e << sp; } cout << next #define FAST ios::sync_with_stdio(false); cin.tie(nullptr) #define size(s) (s).size() #define all(vec) (vec).begin(), (vec).end() #define pb(e) push_back(e); #define INF 1e+8 #define PI acos(-1) using ll = long long; using ull = unsigned long long; ll MOD = 1000000007; deque de; int main(){ int n; cin >> n; rep(i, n){ int t; char c; cin >> t >> c; if(t == 0){ de.pb(c); }else{ de.push_front(c); } } for(char & it : de){ cout << it; } cout << endl; }