#include<iostream>
#include<vector>
using namespace std;
int main(){
  int a,b;
  for(int c=0; cin >>a>>b,a||b; c++){
    if(c){cout<<endl;}
    vector<int> year;
    for(int i=a; i<=b; i++){
      if(!(i%4) && i%100){year.push_back(i);}
      else if(!(i%400)){year.push_back(i);}
    }
    if(year.empty()){cout<<"NA"<<endl;}
    else{for(int i=0; i<year.size(); i++){cout <<year[i]<<endl;}}
  }
  return 0;
}