#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
	int c,d,i,j,k,f;
	vector<int> a,b;
	while(cin >> c >> d) {
		if (c+d==0) break;
		a.push_back(c); b.push_back(d);
		}
	k=a.size();
	for (i=0;i<k;i++) {
		if (i>0) cout << endl;
		j=(a[i] % 4 == 0) ? a[i] : (a[i]/4)*4+4;
		f=0; 
		for (j;j<=b[i];j+=4) {
			if (j % 100 ==0 && j % 400!=0) continue;
			cout << j << endl;
			f=1;
		}
		if (f==0) cout << "NA" << endl;
	}
   return 0;
}