def count(a)
  return a / 4 - a / 100 + a / 400
end
def main
  while (a, b = gets.chomp.split(" ").map(&:to_i)) != [0, 0]
    if count(b) - count(a) == 0
      puts "NA"
    else
      (a - (a % 4) + 4).step(b, 4) do |i|
        puts i if (i % 100 != 0 || i % 400 == 0)
      end
    end
    puts
  end
end
main