#include <stdio.h>

int main(void)
{
    int a, b, y, counter, setcount;
    setcount = 0;
    while(1){
        counter = 0;
        scanf("%d %d", &a, &b);
        setcount++;
        if (a == 0&& b == 0){
            break;
        }
        y = a;
        if (setcount != 1)// print a line at the begining if it != the first set
            {
                printf("\n");
            }
        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){//detech whether leap year appears
            printf("NA\n");
        }
    }
    return 0;
}
        
    