program ABC158_D
  character(300000)::S,R
  integer::Q,T,F,rev
  character(5)::query
  character(1)::C
  read(5,*)S
  read(5,*)Q
  N=len_trim(S)
  rev=0
  do I=1,Q
     read(5,'(A)')query
     if(query(1:1)=='1') then
        rev=rev+1
     else
        read(query,*)T,F,C
        if(F==1) then
           if(mod(rev,2)==1) then
              S(N+1:N+1)=C
              N=N+1
           else
              do J=N,1,-1
                 S(J+1:J+1)=S(J:J)
              end do
              S(1:1)=C
              N=N+1
           end if
        else
           if(mod(rev,2)==1) then
              do J=N,1,-1
                 S(J+1:J+1)=S(J:J)
              end do
              S(1:1)=C
              N=N+1
           else
              S(N+1:N+1)=C
              N=N+1
           end if
        end if
     end if
  end do
  if(mod(rev,2)==1) then
     do I=1,N
        R(I:I)=S(N+1-I:N+1-I)
     end do
     write(6,*)R(1:N)
  else
     write(6,*)S(1:N)
end program ABC158_D