import Control.Monad

main :: IO ()
main = do
  t <- readLn
  if t == 0
    then return ()
    else do
      n <- readLn
      ls <- replicateM n getLine
      let ls' = map (map read . words) ls
      putStrLn $ solve t ls'
      main

solve :: Int -> [[Int]] -> String
solve t []
  | t <= 0 = "OK"
  | otherwise = show t
solve t ([a,b]:xs)
  | t <= 0 = "OK"
  | otherwise = solve (t - (b - a)) xs