#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 999999
using namespace std;
int main(){
    int ends=0;
    int A,B;
    while(cin>>A>>B,A){
        if(ends==1)puts("");
        ends=1;
        int FLG=0;
        for(int i=A;i<=B;i++){
            int FLGS=0;
            if(i%4==0)FLGS=1;
            if(i%100==0)FLGS=0;
            if(i%400==0)FLGS=1;
            if(FLGS==1){cout<<i<<endl;FLG=1;}
        }
        if(FLG==0)cout<<"NA"<<endl;
    }
    return 0;
}