#include <iostream>
#include <cstdlib>

using namespace std;

class Date{
private:
	int m_year, m_month, m_day;
	bool m_hasDate;
public:
	Date(int year, int month, int day){
//		cout<<"Date(int year, int month, int day) called"<<endl;
		this->setDate(year, month, day);
	}
	Date(){
//		cout<<"Date() called"<<endl;
		this->setDate(0,0,0);
	}
	virtual ~Date(){
//		cout<<"~Date() called"<<endl;
	}
	void setDate(int year, int month, int day){
		m_year = year; m_month = month; m_day = day;
		m_hasDate = true;
//		cout<<"setDate(int year, int month, int day) called"<<endl;
	}
	void getDate(int &year, int &month, int &day){
		year = m_year; month = m_month; day = m_day;
	}
	int isLeapYear(){
		try{
			if(!m_hasDate){ throw "Date_is_not_setted"; }
		}catch(char* str){
			return -1;
		}
		if (m_year % 400 == 0){ return true;}
		if (m_year % 100 == 0){ return false;}
		if (m_year % 4 == 0){ return true;}
		return false;
	}
};

int main(){

	int a, b;
	class Date date;
	int isLeapYear;
	int nYear;

	while(cin>>a>>b){
		if (a==0 && b==0){break;}
		nYear = 0;
		for(int i=a;i<b;++i){
			date.setDate(i,0,0);
			isLeapYear = date.isLeapYear();
			if(isLeapYear == (-1)){
				cout<<"Data is not set"<<endl;
			}
			if(isLeapYear == 1){cout<<i<<endl; ++nYear;}
		}
		if (nYear == 0){cout<<"NA"<<endl;}
		cout<<""<<endl;
	}
	return 0;
}