#include<iostream>
using namespace std;

bool isLeapYear(int year){
	if (year % 400 == 0)
		return true;
	if (year % 4 == 0){
		if (year % 100 == 0)
			return false;
		else
			return true;
	}
	return false;
}

int main(){
	int a, b, count;

	while (true){
		cin >> a >> b;
		if (a == 0 && b == 0)break;

		count = 0;
		for (int i = a; i <= b; ++i){
			if (isLeapYear(i)){
				++count;
				cout << i << endl;
			}
		}
		if (count == 0)
			cout << "NA" << endl;

		cout << endl;
	}



	return 0;
}