isLeapYear :: Int -> Bool
isLeapYear n
  | rem n 4   /= 0 = False
  | rem n 400 == 0 = True
  | rem n 100 == 0 = False
  | otherwise      = True

listLY :: [Int] -> String
listLY [x,y]
  | listLY' [x,y] == [] = "NA"
  | otherwise           = init $ unlines $ map show  $ listLY' [x,y]
  where
    listLY' [x,y] = filter isLeapYear [x..y]

test = do
  s <- getLine
  if s == "0 0" then return ()
  else do
    putStrLn "\n"
    putStr $ listLY (map read (words s))
    test

main = do
  s <- getLine
  if s == "0 0" then return ()
  else do
    putStr $ listLY (map read (words s))
    test