n = gets.to_i
m = gets.to_i
cards = (1..2*n).to_a

m.times do
  k = gets.to_i
  if k == 0
    new_cards = Array.new
    n.times do |i|
      new_cards << cards[i] << cards[n+i]
    end
    cards = new_cards
  else
    cards = cards[k...2*n] + cards[0...k]
  end
end

puts cards