leap = []
(4...3000).step(4) 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 = [*a..b] & leap
  puts (ret.empty? ? "NA" : ret)
end