#include <iostream>

using namespace std;

int main(){
    int a,b;
    while(cin >> a >> b,a+b){
        bool flg=true;
        for(int i=a;i<=b;i++){
            if(i%4==0){
                if(i%100==0){
                    if(i%400==0){
                        flg=false;
                        cout << i << endl;
                    }
                }else{
                    flg=false;
                    cout << i << endl;
                }
            }
        }
        if(flg){
            cout << "NA" << endl;
        }
        cout << "" << endl;
    }
    return 0;
}