n = gets.to_i
m = gets.to_i

cards = [*1..(2*n)]

m.times do
    k = gets.to_i
    if k==0 then
        tmp = cards.dup
        n.times do |i|
            tmp[i*2+1,0] = cards[n+i]
        end
        cards = tmp[0..(2*n-1)]
    else
        tmp = cards.dup
        tmp[0,0] = cards[k..-1]
        cards = tmp[0..(2*n-1)]
    end
end

#p cards
cards.each do |x| puts x end