#include<iostream>
using namespace std;
int main(){
  int a,b;
  int ans=0,c=0,h=0;
  while(cin>>a>>b){
    if(a==0&&b==0) break;
    if(c!=0) cout << endl;
    for(int i=a;i<=b;i++){
      if(i%4==0){
	if(i%100==0){
	  if(i%400==0){
	    ans = i;
	    continue;
	  }
	  continue;
	}
	ans = i;
      }
      else continue;
      cout << ans << endl;
    }
    if(ans==0) cout << "NA" << endl;
    ans = 0;
    c++;
  }
  return 0;
}