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()
{
	foreach (line; stdin.byLine) {
		auto ab = line.split.map!(to!int);
		if (ab[0] + ab[1] == 0) break;
		bool f;
		foreach (y; ab[0]..ab[1]+1) {
			if (isLeapYear(y)) {
				y.writeln;
				f = 1;
			}
		}
		if (!f) writeln("NA");
		writeln("");
	}
}

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