is_first_time = true
loop do
  a, b = gets.chomp.split.map(&:to_i)
  break if [a,b].all?(&:zero?)
  puts "" unless is_first_time
  count = (a..b).to_a.map do |year|
    if year.odd? || year % 4 != 0 || (year % 100 == 0 && year % 400 != 0)
      0
    else
      year
    end
  end
  if count.all?(&:zero?)
    puts "NA"
  else
    count.select{ |y| y != 0 }.each { |y| puts y }
  end
  is_first_time = false
end