#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int check (int year) {
    bool ret;
    if (year % 400 == 0) {
        ret = true; 
    } else if (year % 100 == 0) {
        ret = false; 
    } else if (year % 4 == 0) {
        ret = true; 
    } else {
        ret = false; 
    }
    return ret;
}

int main(void) {
    bool start = false;
    while (1) {
        int a;
        int b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        } else if (start) {
            cout << endl;
        }
        bool exist = false;
        for (int i = a; i <= b; i++) {
            if (check(i) == true) {
                cout << i << endl;
                exist = true;
            }
        }
        if (exist == false) {
            cout << "NA" << endl;
        }
        start = true;
    }
    return 0;
}