Module D
    Sub Main(ByVal args() As String)
        Dim s As String = Console.ReadLine()
        Dim cnt As Integer = Integer.Parse(Console.ReadLine())
        Dim query As String = ""
        Dim arr() As String
    	For i as integer = 1 To cnt
            query = Console.ReadLine()
            If query(0) = "1" Then
                s = StrReverse(s)
            Else
                arr = Split(query, " ")
                If arr(1) = "1" Then
                    s = arr(2) & s
                Else
                    s = s & arr(2)
                End If
            End If
        Next
        Console.WriteLine(s)
    End Sub
End Module