import scala.io.Source.stdin

object Main extends App {
  def isLeapYear(y:Int) = {
    if(y%4 != 0) false
    else if(y%100 != 0) true
    else if(y%400 != 0) false
    else true
  }

  println {
    stdin.getLines.filter( _.trim != "0 0").map { s=>
      val y = s.split(" ").map(_.toInt)
      val leapYear = for(i<-y(0) to y(1);if isLeapYear(i)) yield i
      if(leapYear.length==0) "NA"
      else leapYear.mkString("\n")
    }.mkString("\n\n")
  }
}