import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    string[] r;
    foreach(s;stdin.byLine())
    {
        auto m = s.split().map!(to!int);
        immutable a=m[0], b=m[1];
        if(a==0 && b==0) break;
        auto ys = iota(a,b+1).filter!(y=>y%400==0 || (y%4==0 && y%100)).array();
        if(ys.length==0) r~="NA";
        else r~=ys.map!(to!string).join("\n");
    }
    r.join("\n\n").writeln();
}