import Control.Monad

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

solve :: Int -> [[Int]] -> String
solve l ls = prof l ls 0
  where
    prof :: Int -> [[Int]] -> Int -> String
    --prof l ls acc count
    prof _ [] _ = "NA"
    prof l ([m,n]:xs) count
      | l - (m - n) <= 0 = show (count + 1)
      | otherwise = prof (l - (m - n)) xs (count + 1)