#include <array>
#include <iostream>

bool isLeapYear(int inputYear)
{
    if (inputYear % 400 == 0) {
        return true;
    } else if (inputYear % 100 == 0) {
        return false;
    } else if (inputYear % 4 == 0) {
        return true;
    } else {
        return false;
    }
}

int main()
{
    do {
        int start;
        int end;

        std::cin >> start;
        std::cin >> end;

        if (start == 0 && end == 0) {
            break;
        }

        if (start >= end) {
            std::cout << "NA" << std::endl;
        }

        for (int i = start; i <= end; i++) {
            if (isLeapYear(i) == true) {
                std::cout << i << std::endl;
            }
        }

        std::cout << std::endl;

    } while (true);
}