// yet

#include <iostream>
#include <complex>
#include <array>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int a,b;
    bool f=0;
    while(cin>>a>>b,a||b){
        if(f) cout<<endl;
        f=1;
        int n=0;
        int ans[3000];
        loop(y,a,b+1){
            if(y%400==0||(y%4==0&&y%100!=0)) ans[n++]=y;
        }
        if(n) rep(i,n) cout<<ans[i]<<endl;
        else cout<<"NA"<<endl;
    }
}