import Data.List(intercalate)
import Control.Applicative
main = do
  v <- map (map (read::String->Int) . words) . lines <$> getContents
  let u = map aux . map leap $ takeWhile (\x->x/=[0,0]) v  
  putStrLn $ intercalate "\n\n" u
  where
    aux::[Int] -> String
    aux [] = "NA"
    aux xs = intercalate "\n" $ map show $ xs

leap::[Int]->[Int]
leap (st:ed:_) = [y|y<-[st..ed], isleap y]
  where
    isleap y = (y `mod` 4 ==0 && y `mod` 100 /= 0) || y `mod` 400 == 0