#include <iostream>
#include <vector>
using namespace std;

int main(){
	int a,b,t=0;

	while(++t){
		vector<int> leap;
		cin>>a>>b;
		
		if(a==0&&b==0) break;
		if(t>1) cout<<endl;

		for(int i=a;i<=b;i++){
			if( i%400==0 || (i%4==0 && i%100!=0)) leap.push_back(i);
		}

		if(leap.size()==0){
			cout<<"NA"<<endl;
		}
		else{
			for(int i=0;i<leap.size();i++){
				cout<<leap[i]<<endl;
			}
		}
	}
	return 0;
}