#encoding:utf-8
def search_leap_year array
 leap_year = []
 while array[0] <= array[1]
  if array[0]%4 == 0 && array[0]%100 != 0 || array[0]%400 == 0
   leap_year.push array[0]
  end
  array[0] += 1
 end

 if leap_year.length == 0
  puts "NA"
 else
  puts leap_year
 end
end

years = []
while true
 year = gets.chomp.split
 if year == %w(0 0)
  break
 end
 year.length.times do |i|
  year[i] = year[i].to_i
 end
 years.push year
end

i = 0
while i < years.length
 unless i == years.length - 1
  search_leap_year years[i]
  puts
 else
  search_leap_year years[i]
 end
 i += 1
end