import Control.Applicative
import Control.Monad

isLeap :: Int -> Bool
isLeap n
    | n `divisible` 400 = True
    | n `divisible` 100 = False
    | n `divisible` 4 = True
    | otherwise = False

divisible :: Int -> Int -> Bool
divisible n m = n `mod` m == 0

leaps :: Int -> Int -> [Int]
leaps a b = filter isLeap [a..b]

step :: Int -> IO ()
step x = do
    [n,m] <- map read . words <$> getLine
    unless (n == 0 && m == 0) $ do
            case leaps n m of
                [] -> putStrLn "NA"
                ys -> do
                    -- ugly because of the specification!!!!
                    unless (x==0) $ putStrLn ""
                    mapM_ print ys
            step (x+1)
main = step 0