Imports System.Text

Module D
    Sub Main(ByVal args() As String)
        Dim sb As StringBuilder = New StringBuilder
        sb.Append(Console.ReadLine())
        Dim cnt As Integer = Integer.Parse(Console.ReadLine())
        Dim query As String
        Dim rv_flg As Boolean = False
        For i As Integer = 1 To cnt
            query = Console.ReadLine()
            If query(0) = "1" Then
                rv_flg = Not rv_flg
            Else
                If Not rv_flg Then
                    If query(2) = "1" Then
                        sb.Insert(0, query(4))
                    Else
                        sb.Append(query(4))
                    End If
                Else
                    If query(2) = "1" Then
                        sb.Append(query(4))
                    Else
                        sb.Insert(0, query(4))
                    End If
                End If
            End If
        Next
        Console.WriteLine(If(rv_flg, StrReverse(sb.ToString()), sb.ToString()))
    End Sub
End Module