program string_formation
  implicit none
  character(100000) :: s
  character(500000) :: ans = ""
  character(5) :: t
  integer :: q, l, r, i, f
  logical :: reversed = .false.
  read(*,*) s
  l = 200001
  r = 200000+len_trim(s)
  ans(l:r) = s(1:len_trim(s))
  read(*,*) q
  do i = 1, q
    read(*,'(a)') t
    if (t(1:1) == "1") then
      reversed = .not.reversed
      cycle
    end if
    f = ichar(t(3:3))-48
    if (f == 1 .eqv. reversed) then
      r = r+1
      ans(r:r) = t(5:5)
    else
      l = l-1
      ans(l:l) = t(5:5)
    end if
  end do
  if (reversed) then
    do i = l, r
      f = l+r-i
      if (i >= f) exit
      t(1:1) = ans(i:i)
      ans(i:i) = ans(f:f)
      ans(f:f) = t(1:1)
    end do
  end if
  write(*,'(a)') ans(l:r)
end program string_formation