#include <iostream>
#include <algorithm>
using namespace std;

bool isLeap(int y) {
  if(y % 400 == 0) return true;
  if(y % 100 == 0) return false;
  return y % 4 == 0;
}

int main() {
  int a, b;
  bool first = true;
  while(cin >> a >> b && (a|b)) {
    if(first) first = false;
    else cout << endl;
    bool flag = false;
    for(int i = a; i <= b; ++i) {
      if(isLeap(i)) {
        cout << i << endl;
        flag = true;
      }
    }
    if(!flag) cout << "NA" << endl;
  }
  return 0;
}