#include<stdio.h>

void leap(int x, int y)
{
    int count = 0;

    for(int i = x; i < y; i++) {
        if (((i % 4 == 0) && (i % 100 != 0)) || (i % 400 == 0)) {
            printf("%d\n", i);
            count = 1;
        }
    }

    if (count == 0) {
        printf("NA\n");
    }
}

int main(void)
{
    int num1, num2;

    scanf("%d %d", &num1, &num2);

    while ((num1 != 0) || (num2 != 0)) {
        leap(num1, num2);

        scanf("%d %d", &num1, &num2);
    }

    return 0;
}