#include<iostream>
#include<cstdio>
using namespace std;

int main(){
    int A=-1,B=-1;
    while(cin>>A>>B, A||B){
        if(~A || ~B) puts("");
        bool no = true;
        for(int i=A;i<=B;i++){
            if(i%4==0 && (i%100!=0 || i%400==0)) printf("%d\n",i), no = true;
        }
        if(no) puts("NA");
    }
    return 0;
}