#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define sz(obj) ((int)(obj).size())
#define pb push_back

int main()
{
  int a, b;
  while (cin >> a >> b, a + b){
    vector<int> v;
    FOR(i, a, b + 1){
      if (i % 400 == 0) v.pb(i);
      else if (i % 4 == 0 && i % 100 != 0) v.pb(i);
    }
    if (sz(v)) REP(i, sz(v)) cout << v[i] << endl;
    else cout << "NA" << endl;
  }
}