#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

int main()
{
	int a, b;
	bool line, flag, year[3000]={0};
	for(int i=1; i<3000; i++){
		if(i % 4 == 0){
			if(i % 100 == 0){
				if(i % 400 == 0) year[i] = true;
				else year[i] = false;
			}else year[i] = true;
		}
	}

	line = false;
	while(1){
		cin >> a >> b;
		if(a == 0) break;

		if(line)
			cout << endl;
		line = true;

		flag = false;
		for(int i=a; i<=b; i++){
			if(year[i]){
				flag = true;
				cout << i << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}