#include <iostream>
using namespace std;

bool is_uruu (int y) {
    if (y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)) return true;
    return false;
}

int main ()
{
    int a, b;
    bool f = false;
    while (cin >> a >> b, (a or b)) {
        if (f) cout << endl;
        f = true;
        bool flag = true;
        while (a <= b) {
            if (is_uruu(a)) {
                cout << a << endl;
                flag = false;
            }
            a++;
        }

        if (flag) cout << "NA" <<endl;
    }

    return 0;
}