module AOJ_Volume0093;

import std.stdio,std.string,std.conv;

int main()
{
	bool first = true;
	while(true)
	{
		string[] s = readln.chomp.split(" ");
		int a = s[0].to!int;
		int b = s[1].to!int;

		if(a == 0 && b == 0) break;

		if(first)
		{
			first = false;
		}
		else
		{
			writeln;
		}

		bool flag = true;
		foreach(i;a..b+1)
		{
			if(i%400 == 0)
			{
				flag = false;
				i.writeln;
			}
			else if(i%100 != 0 && i%4 == 0)
			{
				flag = false;
				i.writeln;
			}
		}

		if(flag) "NA".writeln;
	}
	return 0;
}