#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int leapyear(int year){
  return (year%4!=0||(year%100==0&&year%400!=0) ?0:1);
}
int main(){
int a,b;
int e=0;
while(cin>>a>>b,a||b){
int co=0;
if(e!=0)cout<<endl;
loop(i,a,b+1){
if(leapyear(i)==1){co++;cout<<i<<endl;}
}
if(co==0)cout<<"NA"<<endl;
e++;
}
}