#include <iostream>


int leap_year(int y) {
	if( y % 400 == 0) {
		return 1;/*???????????´*/
	} else if (y % 100 == 0 && y % 400 != 0) {
		return 0;/*???????????´??§??????*/
	} else if (y % 4 == 0 && y % 100 != 0) {
		return 1;
	} else {
		return 0;
	}
}
int main()
{
	int a, b;
	int n =0;/*???????????°-1*/
	while (true) {
		std::cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		} else {
			if (n >0) {
				std::cout << std::endl;/*1?????????????????\?????§??????????????????*/
			}
			int sum = 0;
			for (int k = a; k <= b; k++) {
				sum = sum + leap_year(k);
			}
			if (sum == 0 /*????????????????????´?????????*/) {
				std::cout << "NA" << std::endl;
			} else {
			    for (int i =a; i <= b; i++) {
					if (leap_year(i) == 1) {
						std::cout << i << std::endl;
					}
				}
			}
		}
	n++;
	}
	return 0;
}