import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  val OriginalDirection = true;
  
  while (input.hasNext()) {
    val S = StringBuilder(input.next()) 
    val Q = input.nextInt()
    var direction = OriginalDirection;
    
    for (i in 1..Q) {
      val q = input.nextInt()
      
      if (q == 1) {
        direction = !direction
      } else if (q == 2) {
        val F = input.nextInt()
        val C = input.next()
        
        if (direction == OriginalDirection) {
          if (F == 1) {
            S.insert(0, C)
          } else if (F == 2) {
            S.append(C)
          }
        } else {
          if (F == 1) {
            S.append(C)
          } else if (F == 2) {
            S.insert(0, C)
          }
        }
      }    
    }
    
    if (direction == OriginalDirection) {
      println(S)
    } else {
      println(S.reverse())
    }
  }
}