Imports System.Text

Module Module1

    Sub Main()
        Dim ans As String = ""

        Dim getvaluelength As Integer


        Dim mojiretu As String = Console.ReadLine()

        getvaluelength = CInt(Console.ReadLine())


        Dim sb As New System.Text.StringBuilder
        sb.Append(mojiretu)

        Dim revflg As Boolean = False

        For i As Integer = 0 To getvaluelength - 1
            Dim tempval() As String = Console.ReadLine.Split(" "c)

            If tempval(0) = "1" Then

                revflg = Not revflg

            ElseIf tempval(0) = "2" Then

                If tempval(1) = "1" Then
                    If revflg Then
                        sb.Append(tempval(2))
                    Else
                        sb.Insert(0, tempval(2))
                    End If


                ElseIf tempval(1) = "2" Then

                    If revflg Then
                        sb.Insert(0, tempval(2))
                    Else
                        sb.Append(tempval(2))
                    End If
                End If
            End If

        Next


        If revflg Then
            ans = Microsoft.VisualBasic.Strings.StrReverse(sb.ToString)
        Else
            ans = sb.ToString
        End If



        Console.WriteLine(ans)
        Console.ReadKey()



    End Sub




End Module