def is_leap_year(y)
  return y%4==0&&y%100!=0 || y%400 == 0;
end

fst = true

loop do
  a, b = gets.split.map(&:to_i)

  if a == 0 && b == 0
    break
  end

  if !fst
    puts ""
  end

  fst = false
  
  fl = false
  
  for i in a...b
    if is_leap_year i
      print i, "\n"

      fl = true
    end
  end

  if !fl
    puts "NA"
  end
end