isLeapYear y | y`mod`400==0 = True
             | y`mod`100==0 = False
             | y`mod`4==0   = True
             | otherwise    = False

leapYears [a,b] = let ly = [show y|y<-[a..b],isLeapYear y]
                  in if length ly == 0
                      then ["NA\n"]
                      else ly ++ [""]

main = getContents>>=mapM_ putStrLn.init.concat.map (leapYears.map(read::String->Int).words).init.lines