import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Deque deque = new LinkedList<>(); for(int i = 0; i < n; i++) { int t = sc.nextInt(); char c = sc.next().charAt(0); if(t == 0) { // tail deque.addLast(c); } else { // head deque.addFirst(c); } } StringBuilder sb = new StringBuilder(); while(!deque.isEmpty()) sb.append(deque.pollFirst()); System.out.println(sb.toString()); } }