#include <iostream>

int leap_year(int year)
{
	if ( year % 4 == 0) {
		if ( year % 100 == 0) {
			if ( year % 400 == 0) {
				return 1;
			} else {
				return 0;
			}
		} else {
			return 1;
		}
	} else {
		return 0;
	}
}

int main()
{
	int a, b;
	
	while (true) {
		std::cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		} else {
			int i = 0;
			for (int j = 0; a + j <= b; j++) {
				if (leap_year(a + j) == 0) {
					i++;
				} else {
					std::cout << a + j << std::endl;
				}
			}
			if ( i = a - b + 1) {
				std::cout << "NA" << std::endl;
			}
			
			std::cout << std::endl;
		}
	}
	
	return 0;
}