#include <iostream>
using namespace std;

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

int main(){
	int a, b;
	while(cin >> a >> b){
		if(a == 0 && b == 0) break;
		int count = 0;
		for(int i = a; i <= b; i++){
			if(is_uruu(i)){
				cout << i << endl;
				count++;
			}
		}
		if(count == 0){
			cout << "NA" << endl << endl;
		}else{
			cout << endl;
		}
	}
	return 0;
}