#include <iostream>

using namespace std;

bool isLeap(int y){
	if(y % 400 == 0) return true;
	if(y % 100 == 0) return false;
	if(y % 4 == 0) return true;
	return false;
}

int main(){
	int a, b;
	bool f;
	while(true){
		f = false;
		cin >> a >> b ;
		if(a == 0 && b == 0) return 0;
		for (int i = a; i < b + 1; i++){
			if(isLeap(i)) {
				cout << i << endl;
				f = true;
			}
		}
		if(!f) cout << "NA" << endl;
		cout << endl;
	}
	return 0;
}