#include <iostream>
#include <vector>

using namespace std;

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

  while (1) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
  }
  for (int i = a; i <= b; i++)
    if (i % 400 == 0 || (i % 100 && i % 4 == 0))
      leap.push_back(i);
  if (leap.empty()) {
    cout << "NA" << endl;
    return 0;
  } else {
    for (int i = 0; i < leap.size(); i++)
      cout <<  leap[i] << endl;
  }
  return 0;
}