object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
        for (Array(a, b) <- in if a != 0) {
            (a to b).filter(n => (n % 4 == 0 && n % 100 != 0) || n % 400 == 0) match {
                case l if (l.isEmpty) => println("NA");println()
                case l  => l.foreach(println);println()
            }
        }
    }
}