MAX = 3000
leap = (4...MAX).step(4).to_a - (100...MAX).step(100).to_a + (400...MAX).step(400).to_a
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