#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  bool is_leap[3010] = {};
  for (int i = 0; i <= 3000; i++) {
    is_leap[i] = i % 400 == 0 || (i % 100 != 0 && i % 4 == 0);
  }
  int a, b;
  bool flag = false;
  while (cin >> a >> b, a) {
    if (flag) cout << endl;
    vector<int> ans;
    for (int i = a; i <= b; i++) {
      if (is_leap[i]) ans.emplace_back(i);
    }
    if (ans.empty()) cout << "NA" << endl;
    else {
      for (auto i : ans) {
        cout << i << endl;
      }
    }
    flag = true;
  }

  return 0;
}
