object Main extends App {
	var S = scala.io.StdIn.readLine.toList.map(_.toString)
	val q = scala.io.StdIn.readInt

	var front = List[String]()
	var back  = List[String]()

	var reverse_flag = false

	for(i<-0 until q){
		val a = scala.io.StdIn.readLine.split(" ")

		if(a(0).toInt == 1){
			reverse_flag = !reverse_flag
		}else{

			if(reverse_flag){
				if(a(1).toInt == 2) front = a(2) :: front
				else back = a(2) :: back
			}else{
				if(a(1).toInt == 1) front = a(2) :: front
				else back = a(2) :: back				
			}
		}
	}

	val frontString = front.mkString
	val SString     = S.mkString
	val backString  = back.mkString.reverse

	val ans = frontString + SString + backString

	if(reverse_flag){
		println(ans.reverse)
	}else{
		println(ans)
	}

}