#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int a, b;
        cin >> a >> b;
        if(a == 0)
            return 0;

        bool na = true;
        for(int i=a; i<=b; ++i){
            if(i%400 == 0 || (i%100 != 0 && i%4 == 0)){
                cout << i << endl;
                na = false;
            }
        }
        if(na)
            cout << "NA" << endl;
        cout << endl;
    }
}