#encoding:utf-8 No.0093 2014.10.3
years = []
while true
  range = gets.chomp.split.map{|item|
    item = item.to_i
  }
  if range == [0,0]
    break
  end
  years.push range
end

answer =[]

years.length.times do |i|
  leap_year = []
  for n in years[i][0]..years[i][1]
    if (n%4 == 0 && n%100 != 0) || n%400 == 0
      leap_year.push n      
    end
  end
  if leap_year.length == 0
    leap_year.push "NA"
  end
  answer.push leap_year
end

answer.length.times do |i|
  puts answer[i]
  unless i == answer.length - 1
    puts
  end
end