local s = io.read()
local q = io.read("*n", "*l")
local w = true
local left, right = {}, {}
for i = 1, q do
  local sq = io.read()
  if sq == "1" then
    w = not w
  else
    local f, c = sq:sub(3, 3), sq:sub(5, 5)
    if f == "1" then
      if w then
        table.insert(left, c)
      else
        table.insert(right, c)
      end
    else
      if w then
        table.insert(right, c)
      else
        table.insert(left, c)
      end
    end
  end
end
if w then
  for i = #left, 1, -1 do
    io.write(left[i])
  end
  io.write(s)
  for i = 1, #right do
    io.write(right[i])
  end
  io.write("\n")
else
  for i = #right, 1, -1 do
    io.write(right[i])
  end
  io.write(s:reverse())
  for i = 1, #left do
    io.write(left[i])
  end
  io.write("\n")
end
