#include<iostream>
using namespace std;

int p[3000];

void leap(){
	fill(p, p+3000, false);
	for(int i=1; i < 3000; i++){
		if(i % 400 == 0) p[i] = true;
		else if(i % 100 == 0) continue;
		else if(i % 4 == 0) p[i] = true;
	}
}

int main(){
	leap();
	int a, b;
	bool hoge = false;
	while(cin >> a >> b, a || b){
		bool empty = false;
		if(!hoge) hoge = true;
		else cout << endl;

		for(int i=a; i <= b; i++){
			if(p[i]){
				cout << i << endl;
				empty = true;
			}
		}
		if(!empty) cout << "NA" << endl;
	}
}