#include<iostream>
using namespace std;

int uru(int y);

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

}


int uru(int y){
	if(y%4==0){
		if(y%100==0){
			if(y%400==0)return 1;
			return 0;
		}
		return 1;
	}
	return 0;
}