use std::io::Read; fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let n: usize = it.next().unwrap().parse().unwrap(); let mut deq = std::collections::VecDeque::new(); for _ in 0..n { let op: usize = it.next().unwrap().parse().unwrap(); let c: char = it.next().unwrap().chars().next().unwrap(); if op == 0 { deq.push_back(c); } else { deq.push_front(c); } } let ans: String = deq.into_iter().collect(); println!("{}", ans); } fn main() { run(); }