#include <iostream>
using namespace std;
#include <algorithm>
#include <stdio.h>
int main(void)
{
	int a[100], b[100], i = 0, j, k;
	bool flag = false;
	
	while (1){
		cin >> a[i] >> b[i];
		if (a[i] == 0 && b[i] == 0) break;
		if (a[i] % 400 < 400 - 4){ a[i] += 4 - (a[i] % 4); }
		i++;
	}
	for (j = 0; j <= i; j++){
		if (j != 0) { printf("\n"); }
		for (k = a[j]; k < b[j];k+=4){
			if (k % 100 == 0){
				if (k % 400 == 0) {
					printf("%d\n", k); 
					flag = true; 
				}
			}
			else {
				printf("%d\n", k);
				if (k % 400 > 400 - 4){
					printf( "%d\n", k + (400 - (k % 400)) ); 
				}
				flag = true;
			}
		}
		if (flag == false) { printf("NA\n"); }
		flag = false;
	}
}