MAX = 3000
leap = (4...MAX).step(4).select{|n| n % 100 > 0 || n % 400 == 0}
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