#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    bool x = true;
    for(;;){
        int a, b;
        cin>>a>>b;
        if(a==0&&b==0)return 0;
        if(!x)cout<<endl;
        else x=false;

        bool y=true;
        for(int i=a;i<=b;++i){
            if(i%400 == 0||(i%100!=0&&i%4==0)){
                cout<<i<<endl;
                y=false;
            }
        }
        if(y)cout <<"NA"<< endl;
    }
}