def isLeapYear? year
    return true if (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)
    false
end

answers = []
while true
    year1, year2 = gets.chomp.split.map(&:to_i)
    break if year1 == 0 && year2 == 0
    answers << []
    year1.upto(year2){|year| answers.last << year if isLeapYear?(year)}
end

answers.each_with_index{|answer, index|
    puts if index != 0
    if answer.size == 0
        puts "NA"
    else
        puts answer
    end
}