while gets
  a, b = $_.split.map(&:to_i)
  break if a == 0 && b == 0
  puts if $<.lineno > 1

  n = a % 4 == 0 ? a : a + (4 - a % 4)
  leap = (n..b).step(4).select{|i| i if i % 100 > 0 || i % 400 == 0}
  puts (leap.empty? ? "NA" : leap)
end