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

v = $stdin.gets.split(" ").map{|e| e = e.to_i}
while v[0] != 0 && v[1] != 0
  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}
    puts
  end
  v = $stdin.gets.split(" ").map{|e| e = e.to_i}
end