import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); StringBuilder sb0 = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); for (int i = 0; i < n; i++) { sa = br.readLine().split(" "); if (sa[0].equals("0")) { sb0.append(sa[1]); } else { sb1.append(sa[1]); } } br.close(); sb1.reverse(); sb1.append(sb0); System.out.println(sb1.toString()); } }