#include <iostream>
#include <vector>
using namespace std;

bool isLeapYear(int y);
int main(){
  int a,b;
  vector<int> A,B;
  while(1){
    cin>>a>>b;
    if(a<0||b<0||a>b||a>3000||b>3000)
      return 1;
    if(a==0&&b==0)
      break;
    A.push_back(a),B.push_back(b);

  }
  for( int i=0;i<A.size();i++ ){
    int leapnum=0;
    for( int j=A[i];j<=B[i];j++ ){
      if(isLeapYear(j)){
	leapnum++;
	cout<<j<<endl;
      }
    }
    if(!leapnum){
      cout<<"NA"<<endl;
    }
    if( i!=A.size()-1 )cout<<endl;
  }
  return 0;
}

bool isLeapYear(int y){
  if(!(y%4)&&(y%100))
    return true;
  if( !(y%400) )
    return true;
  return false;
}