MAX = 3000
leap = {}.tap{|h| (4...MAX).step(4).each{|n| h[n] = true if 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).select{|n| leap[n]}
  puts (ret.empty? ? "NA" : ret)
end