list=Array.new(3001,nil)
loop do
  a,b=gets.split.map(&:to_i)
  break if a==0 and b==0
  count=[]
  (a..b).each do |year|
    if list[year]==1
      count<<year
    elsif list[year].nil?
      if year%400==0 or (year%4==0 and year%100!=0)
        count<<year
        list[year]=1
      else
        list[year]=0
      end
    end
  end
  puts count.empty? ? "NA" : count
  puts ""
end