require 'date'
while t=gets
  n,m=t.split.map(&:to_i)
  if n==0 && m==0 then break end
  f=true
  for i in n.. m
    d=Date.new(i)
    if d.leap?
      puts d.year
      f=false
    end
  end
  if f
    puts "NA"
  end
  puts ""
end