#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,cnt=0,na;
    while(1)
    {
        na=0;
        if(cnt!=0)cout<<endl;
        cin>>a>>b;
        if(a==0&&b==0)break;
        cnt++;
        for(int i=a;i<b+1;i++)
        {
            if(i%4==0&&i%100!=0)
            {
                cout<<i<<endl;
                na++;
            }
            else if(i%400==0)
            {
                cout<<i<<endl;
                na++;
            }
        }
        if(na==0)cout<<"NA"<<endl;
    }
    return 0;
}