def leap_year?(year)
  year % 400 == 0 || (year % 100 != 0) && (year % 4 == 0)
end

loop do
  a,b = gets.chomp.split(' ').map(&:to_i)
  break if a|b == 0
  leap_year_found = false
  (a..b).each do |year|
    if leap_year?(year)
      puts year
      leap_year_found = true
    end
  end

  unless leap_year_found
    puts "NA"
  end

  puts ""
end