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

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