#include <iostream>
#include <vector>
using namespace std;

int main() {
	int a, b;
	bool first = true;
	for (cin >> a >> b; a && b; cin >> a >> b) {
		if (first) {
			first = !first;
		}
		else {
			cout << endl;
		}
		vector<int> years;
		int i;
		for (i = a + 1; i < b; ++i) {
			if (i % 400 == 0 || (i % 4 == 0 && i % 100)) {
				years.push_back(i);
				break;
			}
		}
		for (i += 4; i < b; i += 4) {
			if (i % 100 || i % 400 == 0) {
				years.push_back(i);
			}
		}
		if (years.empty()) {
			cout << "NA" << endl;
		}
		else {
			for (int i = 0; i < years.size(); ++i) {
				cout << years[i] << endl;
			}
		}
	}
	return 0;
}