#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

int main()
{
    bool is_leap[3000] = {};
    for( int i=1; i<3000; ++i ) {
        if ( i % 4 == 0 ) {
            if ( i % 100 == 0 ) {
                if ( i % 400 == 0 ) {
                    is_leap[i] = true;
                }
            } else {
                is_leap[i] = true;
            }
        }
    }

    int a, b;
    bool d=false;
    while( cin >> a >> b, a||b ) {
        vector<int> v;
        for( int i=a; i<=b; ++i ) {
            if ( is_leap[i] )
                v.push_back( i );
        }

        if ( d )
            cout << endl;
        else
            d = true;

        if ( v.empty() ) {
            cout << "NA" << endl;
        } else {
            copy( v.cbegin(), v.cend(), ostream_iterator<int>( cout, "\n" ) );
        }
        
    }
}