#include<iostream>
using namespace std;
int main(){
	int a,b;
	while(1){
	cin >> a >> b; 
	if(a ==0 && b == 0) return 0;
	int k = 0;
	if(b - a < 4){
	for(int i = a;i<=b;i++){
		if(i % 400 == 0){ 
		cout << i << endl; k++;
		} else if(i % 100 == 0){
		break;  
		} else if(i % 4 == 0){
			cout << i << endl; k++;
		
		}
	}
	if(k == 0){
	cout << "NA" << endl ;
	} else {cout << endl; return 0;}
	}
	
	for(int i = a;;i++){
		if(i % 4 == 0){
		a = i; break;
		}
	}
	for(int i = a ;i<=b;){
		if(i % 400 == 0){ 
			cout << i << endl;} else 
		if(i % 100 == 0){
		if(i % 100 == 0) break;  
		} else if(i % 4 == 0){
		cout << i << endl;
		
		}
		i+=4;
		}
		cout << endl;		
		}
	}