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

def solve(a, b)
  ans = []
  a.upto(b) do |y|
    ans.push(y) if leap_year?(y)
  end

  if ans.empty?
    puts 'NA'
  else
    ans.each {|y| puts y}
  end
end

first_answer = true

while true
  a, b = gets.split.map(&:to_i)
  break if a == 0 and b == 0

  puts unless first_answer
  solve(a, b)
  first_answer = false
end