#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
 
int main()
{
	int a,b;	
	while(1){
		cin>>a>>b;
		if(a==0 && b==0) return 0;
		if(a%4!=0) a=a-(a%4)+4;
		if((a%100==0)&&(a%400!=0)) a+=4;

		if(a>b) cout<< "NA" <<endl;
		else {
			for(int i=0;a<=b;a=a+i){
				if((a%100==0)&&(a%400!=0)) continue;
				cout << a << endl;
				i=4;	
			}
		}
	}
}