let st = stdin.ReadLine()
let q = stdin.ReadLine() |> int
let qr = [1..q] |> List.map (fun _ -> stdin.ReadLine().Split())
let rec f c i s =
    if i=q then
        s
        |> (Seq.toList >> List.map string)
        |> fun x -> if c%2=1 then List.rev x else x
        |> List.reduce (fun ans x -> ans + x)
    elif qr.[i].[0]="1" then f (c+1) (i+1) s
    elif (qr.[i].[1]="1" && c%2=0) || (qr.[i].[1]="2" && c%2=1)  then f c (i+1) (qr.[i].[2] + s)
    else f c (i+1) (s + qr.[i].[2])
f 0 0 st |> stdout.WriteLine