stack = []
until (years = $<.gets.split.map(&:to_i)) == [0, 0]
  is_uruu = ->(year) {
    (year % 4).zero? and ((year % 100).nonzero? or (year % 400).zero?)
  }
  result = (years.first..years.last).map {|i| is_uruu.(i) ? i : nil}.compact
  result << "NA" if result.empty?
  stack << result.join("\n") 
end
print stack.join("\n\n") + "\n"
