leap = []
(1...3000).each do |n|
  case
    when n % 400 == 0;
    when n % 100 == 0; next
    when n % 4 != 0; next
  end
  leap << n
end

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

  ret = leap.each_with_object([]) do |n, o|
    break o if n > b
    next if n < a
    o << n
  end

  puts (ret.length == 0 ? "NA" : ret)
end