#include #define rep(i,n) for(int i=0; i<(n); i++) using namespace std; typedef long long ll; int main(){ int n; cin>>n; deque que; rep(i,n){ int t; char s; cin>>t>>s; (t==1?que.push_front(s):que.push_back(s)); } for(auto x: que) cout<