main = interact $ unlines . map (show . uncurry hanafuda) . read' . lines
 where
  read' ("0 0":_) = []
  read' (nr:xs) = (reverse [1..n], map (map read . words) xs1) : read' xs2 
   where
    [n,r] = map read (words nr)
    (xs1,xs2) = splitAt r xs

hanafuda d [] = head d
hanafuda d ([p,c]:pcs) = hanafuda (dm ++ dt ++ db) pcs
 where
  dt = take (p-1) d
  dm = take c (drop (p-1) d)
  db = drop (p+c-1) d