import std.stdio;                                                       
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;


bool is_uruu(int n) {
	return n%400 == 0 || (n%100 != 0 && n%4 == 0);
}
void main() {
	bool f = false;
	while(true) {
		int a, b;
		auto s = readln().strip().split();
		a = to!int(s[0]);
		b = to!int(s[1]);
		if((a|b) == 0)
			break;
		if(f){
			writeln();
		}else{
			f = true;
		}

		int c;
		foreach(int n; a..b+1) {
			if(is_uruu(n)){
				writeln(n);
				++c;
			}
		}
		if(c == 0)
			writeln("NA");
	}
}