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

def main
  a,b = gets.chomp.split(' ').map(&:to_i)
  return if a|b == 0

  loop do
    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

    a,b = gets.chomp.split(' ').map(&:to_i)
    break if a|b == 0

    puts ""
  end
end

main