#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //cout << fixed << setprecision(7);

    int a, b;
    int cnt = 0;
    while (cin >> a >> b)
    {
        if (a == 0 && b == 0)
            break;
        if (cnt)
            cout << endl;
        vector<int> ans;
        for (int year = a; year <= b; ++year)
        {
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
                ans.push_back(year);
        }
        cnt++;
        if (ans.size() == 0)
        {
            cout << "NA" << endl;
        }
        else
        {
            for (auto e : ans)
                cout << e << endl;
        }
    }
    return 0;
}
