answers = Array.new
while line = $stdin.gets.chomp
	range = line.split( / / )
	a = range[ 0 ].to_i
	b = range[ 1 ].to_i

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

	ans = Array.new
	a.upto( b ){ |year|
		leap = false
		if year % 400 == 0
			leap = true
		elsif year % 100 == 0
			leap = false
		elsif year % 4 == 0
			leap = true
		else
			leap = false
		end
		ans << year if leap
	}
	answers << ans
end

f = false
answers.each{ |years|
	puts if f
	if years.size == 0
		puts "NA"
		next
	end
	years.each{ |year|
		puts year
	}
	f = true
}
