#include <stdio.h>

int main(void)
{
    int a, b, y, counter;
    while(1){
        counter = 0;
        scanf("%d %d", &a, &b);
        if (a == 0&& b == 0){
            break;
        }
        if (b >= 3000 || a < 0){
            printf("NA\n");
        }else{
            y = a;
            //printf("%d\n", a);
            for (int i = a; i < b; i++){//  y == i
                if (!(y%400)){
                    printf("%d\n", y);
                    counter++;
                }else if((!(y%4)) && y%100){
                    printf("%d\n", y);
                    counter++;
                }
                y++;
            }
            if (counter == 0){
                printf("NA\n");
            }else{
                printf("\n");
            }
        }
    }
    return 0;
}
        
    