Imports System.Text

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