import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	auto ab = readln.split.map!(to!int);
	while (1) {
		bool f;
		foreach (y; ab[0]..ab[1]+1) {
			if (isLeapYear(y)) {
				y.writeln;
				f = 1;
			}
		}
		if (!f) writeln("NA");
		ab = readln.split.map!(to!int);
		if (ab[0] + ab[1] == 0) break;
		writeln("");
	}
}

bool isLeapYear(int year) {
	if (year % 4) return 0;
	if (year % 400 == 0) return 1;
	if (year % 100 == 0) return 0;
	return 1;
}