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