program ABC158_D
  character(100000)::S
  character(1)::Fs(200000),Bs(200000),Ss(300000)
  integer::Q,T,F,rev,Fi,Bi
  character(5)::query
  character(1)::C
  read(5,*)S
  read(5,*)Q
  N=len_trim(S)
  rev=0
  Fi=0
  Bi=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 .and. mod(rev,2)==0) .or. (F/=1 .and. mod(rev,2)==1)) then
           Fi=Fi+1
           Fs(Fi)=C
        else
           Bi=Bi+1
           Bs(Bi)=C
        end if
     end if
  end do
  do I=1,len_trim(S)
     Ss(I)=S(I:I)
  end do
  if(mod(rev,2)==1) then
     write(6,*)Bs(Bi:1:-1),Ss(len_trim(S):1:-1),Fs(1:Fi)
  else
     write(6,*)Fs(Fi:1:-1),Ss(1:len_trim(S)),Bs(1:Bi)
  end if
end program ABC158_D