let cut cards n k =
  Array.append (Array.sub cards k (2*n-k)) (Array.sub cards 0 k);;

let riffle cards n =
  let a = Array.sub cards 0 n and
      b = Array.sub cards n n in
  Array.init (2*n) (fun x -> if x mod 2 = 0 then a.(x/2) else b.( (x-1)/2 ) );;

let () =
  let n = read_int () and
      times = read_int () in
  let init = Array.init (2*n) (fun x -> (x+1)) in
  let rec read cards = function
      0 -> Array.iter (fun x -> Printf.printf "%d\n" x) cards
  | i ->
     let k = read_int () in
     if k = 0 then
       read (riffle cards n) (i-1)
     else
       read (cut cards n k) (i-1)
  in
  read init times;;