import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val s = scn.next().toCharArray()
	var pre = mutableListOf<Char>()
	var suf = mutableListOf<Char>()
	val nq = scn.nextInt()
	var rev = false
	repeat(nq){
		val t = scn.nextInt()
		when(t){
			1 -> rev = !rev
			2 -> {
				val f = scn.nextInt()==2
				val c = scn.next().toCharArray()[0]
				if (f==rev) pre.add(c)
				else suf.add(c)
			}
		}
	}
	if (rev){
		val tmp = suf
		suf = pre
		pre = tmp.asReversed()
		s.reverse()
	}else pre.reverse()
	val ans = buildString {
		append(pre.toCharArray())
		append(s)
		append(suf.toCharArray())
	}
	print(ans)
}
