//13
#include<iostream>

using namespace std;

int main(){
  bool suc=false;
  for(int a,b;cin>>a>>b,a|b;){
    if(suc){
      cout<<endl;
    }
    suc=true;
    bool out=false;
    for(;a<=b;a++){
      if(a%400==0 || (a%4==0&&a%100)){
	cout<<a<<endl;
	out=true;
      }
    }
    if(!out){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}
    