#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int a, b, tmp, tmp2;
	
	while(1){
		cin >> a >> b;
		if(a == 0 && b == 0){
			break;
		}
		tmp = 0;
		for(int i = a; i <= b; i++){
			if(i % 400 == 0 || (i % 100 != 0 && i % 4 == 0)){
				tmp2 = i + 4;
				cout << i << endl;
				tmp++;
				break;
			}
		}
		
		for(int i = tmp2; i <= b; i += 4){
			if(i % 100 != 0 || i % 400 == 0){
				cout << i << endl;
			}
		}
		if(tmp == 0){
			cout << "NA" << endl << endl;
		} else {
			cout << endl;
		}
	}
	
	return 0;
}