#include <iostream>
using namespace std;
void uruu(int, bool&);

int main() {
	int a, b;
	cin >> a >> b;

	while (true) {
		
		bool write = false;

		for (int i = a;i <= b;i++) {
			uruu(i, write);
		}
		if (!write)cout << "NA" << endl;
		
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		cout << endl;
	}

	return 0;
}

void uruu(int year, bool& write) {
	if (year % 400 == 0) {
		cout << year << endl;
		write = true;
		return;
	}
	else if (year % 100 == 0) {
		return;
	}
	else if (year % 4 == 0) {
		cout << year << endl;
		write = true;
		return;
	}
	else {
		return;
	}
}