#include <stdio.h>

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

int main(void)
{
    int a,b;
    leap(a,b); 
    return 0;
}