#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
    int a,b,year,flag;
    int i = 50,j;
    while(scanf("%d %d",&a,&b) && (a!=0 && b !=0) &&(i--))
    {
        flag = 0;
        for(j=a; j<=b; j++)
        {
            if((j%4 == 0 && j%100 != 100) || j%400 ==0 ) {
                cout << j << endl;
                flag = 1;
            }

        }
        if(flag != 1)
            cout << "NA" << endl;
    }
    return 0;
}