s=string.gsub(io.read()," ","")
q=io.read("*n","*l")
should_reverse=0
for i=1,q do
    t=io.read("*n")
    if t==1 then
        should_reverse=should_reverse+1
    else
        f=io.read("*n")
        c=string.gsub(io.read()," ","")
        if f==1 then
            if should_reverse%2==1 then
                s=s..c
            else
                s=c..s
            end
        else
            if should_reverse%2==1 then
                s=c..s
            else
                s=s..c
            end
        end
    end
end
print(should_reverse%2==1 and string.reverse(s) or s)