#include <iostream>

int main()
{
	while (true) {
        int x;
	    int y;
	    int z[3];
	    bool flag[2];
	    int n;
	    std::cin >> x >> y;
	    if (x == 0 && y == 0) break;
	    n = y-x+1;
	    flag[1] = false;
	    for (int i=0; i < n; i ++) {
		    z[0] = (x+i) % 4;
		    z[1] = (x+i) % 100;
		    z[2] = (x+i) % 400;
		    if (z[0] == 0) {
			    if(z[1] == 0) {
				    if(z[2] == 0) {
					    flag[0] = true;
					    flag[1] = true;
				    } else {
					    flag[0] = false;
				    }
			    } else {
				    flag[0] = true;
			    }
		    } else {
	  	  	    flag[0] = false;
	  	    }
	  	    if (flag[0]) std::cout << x+i << std::endl;
	  	 }
	  	 if (~flag[1]) std::cout << "NA" << std::endl;
	}
}
	