#include <iostream>
using namespace std;

int isLeap(int y){
  return y%400==0||(y%4==0&&y%100!=0);
}

int main(void){
  int a,b, isNA;
  bool firstLineFlg=1;
  
  while (cin >> a >> b){
    if (a==0 && b==0) break;
    isNA=1;
    if (firstLineFlg) firstLineFlg = 0;
    else cout << endl;
    for (int i=a; i<=b; i++){
      if (isLeap(i)){
        isNA = 0;
        cout << i << endl;
      }
    }
    if (isNA){
      cout << "NA" << endl;
    }
  }
  
  return 0;
}
