#include <iostream>
bool isLeapYear(int year)
{
    return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}

int main()
{
    int from, to;
    bool found;//???????????´????????£???????????????
    while (true) {
        std::cin >> from >> to;
        if (from == 0 && to == 0) {
            break;
        }
        found = false;
        for (int y = from; y <= to; y++) {
            if (isLeapYear(y)) {
                std::cout << y << std::endl;
                found = true;
            }
        }
        if (!found) {
            std::cout << "NA" << std::endl;
        }
        std::cout << std::endl;
    }
}