STDOUT.sync = true

def leap_year_judge(year)
  case
  when (year % 400).zero?
    true
  when (year % 100).zero?
    false
  when (year % 4).zero?
    true
  else
    false 
  end
end

count = 0

while line = gets do
  a,b = line.split.map(&:to_i)
  leap_count = 0
  break if a == 0 && b == 0
  puts "" unless count == 0
  count += 1

  (a..b).each do |current_year|
    if leap_year_judge(current_year)
      puts current_year
      leap_count += 1
    end
  end
  puts "NA" if leap_count == 0
end