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

inline bool is_leapyear(unsigned int y){
    return (y & 3) == 0 && (y % 100 != 0 || (y / 100 & 3) == 0);
}

void solve(int a, int b){
    bool flag = false;
    for(int i = a; i <= b; i++){
        if(is_leapyear(i)){
            printf("%d\n", i);
            flag = true;
        }
    }
    if(!flag) puts("NA");
}

int main(){
    int a, b;
    bool flag = false;
    while(cin >> a >> b){
        if(a == 0 && b == 0) break;
        if(flag) puts("");
        solve(a, b);
        flag = true;
    }
    return 0;
}