#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  while(b) {
    bool flag = true;
    for (int i = a; i <= b; ++i) {
      if ((i % 400 == 0) ||
          (i % 4 ==0 && i % 100 != 0)) {
        cout << i << endl;
        flag = false;
      }
    }
    if (flag)
      cout << "NA" << endl;

    cin >> a >> b;
    if (b)
      cout << endl;
  }
}
