import Data.Maybe
import Control.Monad
import Control.Applicative

money :: [Int] -> Maybe Int
money [] = Nothing
money [_] = Nothing
money (a:b:_) = Just (a - b)


solver :: [[Int]] -> Int -> Int -> Int -> String
solver [] _ _ _ = "NA"
solver (m:ms) obj now month =
  let newNow = now + fromJust (money m)
  in
      if newNow > obj
        then show (month + 1)
        else solver ms obj newNow (month + 1)


main :: IO()
main = do
  obj <- (read :: String -> Int) <$> getLine
  unless (obj == 0) $ do
    line <- map (map (read :: String -> Int) . words) <$> replicateM 12 getLine
    putStrLn $ solver line obj 0 0
    main