#include <cstdio>
using namespace std;
int main(){
    int a, b, sum, idx = 0;
    for (; ;) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) break;
        if (idx) printf("\n");
        if (a % 4 != 0) {
            while (1) { a++; if (a % 4 == 0) break; }
        }
        sum = 0;
        for (int i = a; i <= b; i+=4) {
            if (i % 100 == 0 && i % 400 != 0) continue;
            printf("%d\n", i);
            sum++;
        }
        if (sum == 0) printf("NA\n");
        idx++;
    }

    return 0;
}


