import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine()
    val q = in.readLine().toInt

    val front = Array.ofDim[Char](20000)
    var frontCount = 0
    val rear = Array.ofDim[Char](20000)
    var rearCount = 0

    var reverse = false

    for {
      _ <- 0 until q
    } {
      in.readLine().split("\\s+").map(_.toCharArray()(0)) match {
        case Array('1') =>
          reverse = !reverse
        case Array('2', f, c) =>
          if (f == '1' && !reverse || f == '2' && reverse) {
            front(frontCount) = c
            frontCount += 1
          } else {
            rear(rearCount) = c
            rearCount += 1
          }
      }
    }

    if (reverse) {
      for {
        i <- (rearCount - 1) to 0 by -1
      } {
        out.print(rear(i))
      }
      out.print(s.reverse)
      for {
        i <- 0 until frontCount
      } {
        out.print(front(i))
      }
    } else {
      for {
        i <- (frontCount - 1) to 0 by -1
      } {
        out.print(front(i))
      }
      out.print(s)
      for {
        i <- 0 until rearCount
      } {
        out.print(rear(i))
      }
    }

    out.println()
    out.flush()
  }
}
