#include<iostream>
using namespace std;

bool Judge_Leap_Year( int x )
{
    bool j = false;
    if( x % 4 == 0 )
        j = true;
    if( x % 100 == 0 )
        j = false;
    if( x % 400 == 0 )
        j = true;
    return j;
}

int main()
{
    int a, b, cnt = 0;
    while( cin >> a >> b )
    {
        if( a == 0 && b == 0 )
            break;
        if( cnt != 0 )          //最初の一回を除いて、空行を出力。
            cout << endl;       //嫌がらせ。
        cnt++;
        bool j = false;
        for( int i = a; i <= b; i++ )
        {
            if( Judge_Leap_Year(i) == true )
            {
                j = true;
                cout << i << endl;
            }
        }
        if( j == false )
            cout <<"NA" << endl;
    }
    return 0;
}
