program main
  implicit none
  character(len=100000) :: S1
  character(len=400000) :: S
  character(len=300000) :: Sout
  character(len=1) :: c
  integer :: i,Q,j,j2,N, ii
  integer :: t, f
  integer :: l,r
  logical :: flag 
  read(*,*) S1
  read(*,*) Q
  N = len_trim(S1)
  l = 200000 - N/2
  r = l + N -1
  S(l:r)  = S1(1:N)
  flag=.true.
  do i = 1, Q
     read(*,*) t
     if (t == 1) then
        backspace(5)
        read(*,*) t
        if (flag ) then
           flag = .false.
        else
           flag = .true.
        end if
     else
        backspace(5)
        read(*,*) t, f, C
        if ( f == 1 ) then
           if (flag) then
              l = l-1
              S(l:l) = C
           else
              r = r+1
              S(r:r) = C
           end if
        else
           if ( .not. flag) then
              l = l-1
              S(l:l) = C
           else
              r = r+1
              S(r:r) = C
           end if
        end if
        N = N + 1
     end if
  end do

  if (flag) then
     Sout(1:N) = S(l:r)
  else
     do i = 1,N
        Sout(i:i) = S(r-i+1:r-i+1)
     end do
  end if
  write(*,'(a)') trim(Sout)
end program main