Module Module1

    Sub Main()
        Dim ans As String = ""

        Dim getvaluelength As Integer


        Dim mojiretu As String = Console.ReadLine()

        getvaluelength = CInt(Console.ReadLine())


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

            If tempval(0) = "1" Then
                mojiretu = Microsoft.VisualBasic.Strings.StrReverse(mojiretu)

            ElseIf tempval(0) = "2" Then

                If tempval(1) = "1" Then
                    mojiretu = tempval(2) & mojiretu
                ElseIf tempval(1) = "2" Then
                    mojiretu = mojiretu & tempval(2)
                End If
            End If

        Next



        Console.WriteLine(mojiretu)
        Console.ReadKey()



    End Sub




End Module
