#include <iostream>

using namespace std;

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