#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

bool is_leap_year(int year){
	if(year % 4 == 0){
		if(year % 400 == 0){
			return true;
		}
		else if(year % 100 == 0){
			return false;
		}
		else{
			return true;
		}
	}

	return false;
}


int main(int argc, char **argv){
	int a, b;
	bool is_first = true;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> a >> b){
#else
	while(std::cin >> a >> b){
#endif
		if(a == 0 && b == 0){ break; }
		if(is_first){
			is_first = false;
		}
		else{
			std::cout << std::endl;
		}
		std::vector<int> leap_years;

		for(int i = a; i <= b; i++){
			if(is_leap_year(i)){
				leap_years.push_back(i);
			}
		}

		if(leap_years.empty()){
			std::cout << "NA" << std::endl;
		}
		else{
			for(int i = 0; i < leap_years.size(); i++){
				std::cout << leap_years[i] << std::endl;
			}
		}
	}

 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}
