#include <stdio.h>

void uru(int year);

int main(void)
{
    int a, b;
    int year;
    int j;
    while (1) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) {
            break;
        } else  {
            for (year = a; year < b; ++year) {
                uru(year);
            }
            if (j == 0) {
                printf("NA\n");
            }
        }
    }
    return 0;
}

void uru(int year)
{
    int j = 0;
    int R4, R100, R400;
    R4 = year % 4;
    R100 = year % 100;
    R400 = year % 400;
    if (R4 == 0 && R100 != 0) {
        printf("%d\n", year);
        ++j;
    } else if (R400 == 0) {
        printf("%d\n", year);
        ++j;
    }
}