#include <iostream>

bool isLeap(int y)
{
	if (y%4 != 0) return false;
	if (y%100 == 0) {
		if (y%400 == 0) return true;
		else return false;
	}
	return true;
}

int main()
{
	int a,b;
	bool first_data = true;
	while (true) {
		std::cin >> a >> b;
		
		if (a==0 && b==0) break;
		
		if (first_data) first_data = false;
		else std::cout << std::endl;
		
		bool exists = false;
		for (int year=a; year<=b; year++) {
			if (isLeap(year)) {
				exists = true;
				std::cout << year << std::endl;
			}
		}
		if (!exists) std::cout << "NA" << std::endl;
		
	}
	return 0;
}

	

