program String_Formation
    implicit none
    character S*400005,C*1,query*100
    character ans(-400005:400005)
    integer Q,l,r,i,T,rev,F
    integer sf(100)

    read *,S,Q
    l = 0
    r = len_trim(S)+1
    rev = 0
    ans(1:) = transfer(S,ans,size=len(S))

    do i = 1, Q
        read (*,'(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
                    ans(r:r) = C
                    r = r+1
                else
                    ans(l:l) = C
                    l = l-1
                endif
            else
                if(mod(rev,2) == 0) then
                    ans(r:r) = C
                    r = r+1
                else
                    ans(l:l) = C
                    l = l-1
                endif
            endif
        endif
    enddo

    if(mod(rev,2) == 0) then
        print *,ans(l+1:r-1)
    else
        print *,ans(r-1:l+1:-1)
    endif


end program String_Formation