Imports System.Text

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

    Private Function reverse(ByVal s As String) As String
        Dim cs() As Char = s.ToCharArray
        Array.Reverse(cs)
        Return New String(cs)
    End Function
End Module