#include <stdio.h>
void leapmaker(int start, int end);
int main(void){
    int Year1 = -1, Year2 = -1;
    while(1)
    {
        if(!(Year1 == -1 && Year2 == -1))
        {
            printf("\n");
        }
        scanf("%d %d", &Year1, &Year2);
        if (Year1 == 0 && Year2 == 0)
        {
            break;
        }

        leapmaker(Year1, Year2);
    }
    return 0;
}
void leapmaker(int start, int end){
    int naflag = 1;
    for(int i = start - start % 4; i <= end; i += 4){
        if (i >= start) if (i % 100 == 0)
        {
            if (i % 400 == 0)
            {
                printf("%d\n", i);
                naflag = 0;
            }
        } else {
            naflag = 0;
            printf("%d\n", i);
        }
    }
    if (naflag == 1)
    {
        printf("NA\n");
    }
}