#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
  int a, b;
  vector <int> hoge, leap;

  while (1) {
    cin  >> a >> b;
    if (a == 0 && b == 0)
      break;
    hoge.push_back(a);
    hoge.push_back(b);
  }
  for (int i = 0; i < hoge.size(); i += 2) {
    for (int j = hoge[i]; j <= hoge[i+1]; j++)
      if (j % 400 == 0 || (j % 100 && j % 4 == 0))
        leap.push_back(j);
    if (!leap.empty()) {
      for (int j = 0; j < leap.size(); j++)
        cout << leap[j] << '\n';
      leap.erase(leap.begin(), leap.end());
    } else {
      cout << "NA" << '\n';
    }
    cout << '\n';
  }
  return 0;
}