object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt)).toSeq.init
        println(in.map(x => (x(0) to x(1)).filter(n => (n % 4 == 0 && n % 100 != 0) || n % 400 == 0) match {
            case l if (l.isEmpty) => "NA"
            case l  => l.mkString("\n")
        }).mkString("\n\n"))
    }
}