#include<iostream>
#include<vector>
using namespace std;
vector<int>aa;
vector<int>bb;
int main() {
	int a, b;
	while (cin >> a >> b) {
		if (a == 0 && b == 0)break;
		aa.push_back(a);
		bb.push_back(b);
	}
	for (int i = 0; i != aa.size(); i++){
		if (bb[i] - aa[i] < 4) {
			cout << "NA\n";
			goto U;
		}
		for (int j = aa[i]; j <= bb[i]; j++){
			if (j % 4 == 0) {
				if (j % 100 == 0){
					if (j % 400 == 0){
						cout << j << endl;
					}
				}
				else cout << j << endl;
			}
		}
	U:cout << endl;
	}
}