#include <iostream>

int leap_year(int y) {
    if( y % 400 == 0) {
        return 1;/*Leap Year*/
    } else if (y % 100 == 0 && y % 400 != 0) {
        return 0;/*Not Leap Year*/
    } else if (y % 4 == 0 && y % 100 != 0) {
        return 1;
    } else {
        return 0;
    }
}
int main()
{
    int a, b;
    int n =0;/*output kaisuu - 1*/
    while (true) {
        std::cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        } else {
            if (n >0) {
                std::cout << std::endl;/*2 kaime ikou no output de kuugyou*/
            }
            int sum = 0;
            for (int k = a; k <= b; k++) {
                sum = sum + leap_year(k);
            }
            if (sum == 0 /*Subete Leap Year de nai*/) {
                std::cout << "NA" << std::endl;
            } else {
                for (int i =a; i <= b; i++) {
                    if (leap_year(i) == 1) {
                        std::cout << i << std::endl;
                    }
                }
            }
        }
    n++;
    }
    return 0;
}