#include <iostream>
#include <cstdio>
using namespace std;
int a, b;
bool isUruu(int year) {
    return((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
}

void solve() {
    bool update = false;
    for(int r = a; r < b; r++) {
        if(isUruu(r)){ cout << r << endl; update = true; }
    }
    if(!update) cout << "NA" << endl;
}

int main(void) {
    while(cin >> a >> b, a|b) {
        solve();
    }
    return(0);
}