def checkLeapYear(y)
  return true if y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)
  return false
end

loop do
  v = $stdin.gets.split(" ").map{|e| e = e.to_i}
  if v[0] == 0 && v[1] == 0
    break
  else
    result = Array.new
    (v[0]..v[1]).each{|y| result << y if checkLeapYear(y) }
    if result.size == 0
      puts "NA"
    else
      result.each{|r| p r}
    end
    puts
  end
end