#include <stdio.h>

void leap_year_judge(int year);

int main(void)
{
	int year_a, year_b;
	while (1) {
		scanf("%d %d", &year_a, &year_b);
		if (year_a == 0 && year_b == 0){
			break;
		} else {
			printf("NA\n");
			for (int i = year_a; i <= year_b; i++) {
				leap_year_judge(i);
			}
		}
	}
	return 0;
}

void leap_year_judge(int year)
{
	if (year % 400 == 0) {
		printf("%d\n", year);
	} else if (year % 4 == 0 && year % 100 != 0){
		printf("%d\n", year);
	}
}