"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

// number一個取得
// eslint-disable-next-line no-unused-vars
const next = () => +cin[cid++];

// 文字列一個取得
// eslint-disable-next-line no-unused-vars
const nextstr = () => cin[cid++];

// BigInteger一個取得
// eslint-disable-next-line no-unused-vars
const nextbig = () => BigInt(cin[cid++]);

// 長さnの配列として取得。aは文字列フラグ
// eslint-disable-next-line no-unused-vars
const nexts = (n, a) =>
    a ? cin.slice(cid, (cid += n)) : cin.slice(cid, (cid += n)).map((a) => +a);

// w個ずつを組にして長さhの配列。aは文字列フラグ。
// eslint-disable-next-line no-unused-vars
const nextm = (h, w, a) => {
    var r = [],
        i = 0;
    if (a) for (; i < h; i++) r.push(cin.slice(cid, (cid += w)));
    else for (; i < h; i++) r.push(cin.slice(cid, (cid += w)).map((a) => +a));
    return r;
};
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
// eslint-disable-next-line no-unused-vars
const xArray = (...args) => {
    var a = args,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + a[0] + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
};
main();

function main() {
    let S = nextstr();
    let Q = next();
    let hanten = false;
    let mae = [];
    let ato = [];
    for (let i = 0; i < Q; i++) {
        let type = next();
        //console.log("type:", type);
        if (type == 1) {
            hanten = !hanten;
        } else {
            let F = next();
            //console.log("F:", F);
            if ((F == 1 && !hanten) || (F == 2 && hanten)) {
                mae.push(nextstr());
            } else {
                ato.push(nextstr());
            }
        }
    }
    let ans = "";
    if (!hanten) {
        ans = mae.reverse().join("") + S + ato.join("");
    } else {
        ans =
            ato.reverse().join("") +
            S.split("").reverse().join("") +
            mae.join("");
    }
    console.log(ans);
    return;
}
