use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: String = iterator.next().unwrap().to_string();
    let q: usize = iterator.next().unwrap().parse().unwrap();

    let mut vec: VecDeque<char> = s.chars().collect::<VecDeque<char>>();

    let mut is_reverse = false;
    for _i in 0..q {
        let t = iterator.next().unwrap();
        if t == "1" {
            is_reverse = !is_reverse;
        } else {
            let f = iterator.next().unwrap();
            let c = iterator.next().unwrap().chars().next().unwrap();
            if f == "1" {
                if is_reverse {
                    vec.push_back(c);
                } else {
                    vec.push_front(c);
                }
            } else {
                if is_reverse {
                    vec.push_front(c);
                } else {
                    vec.push_back(c);
                }
            }
        }
    }

    if is_reverse {
        vec.into_iter().rev().collect::<String>()
    } else {
        vec.into_iter().collect::<String>()
    }
}