#include <iostream>
using namespace std;

int judge(int n){
  int flg = 0;
  if(n%4 == 0) flg = 1;
  
  if(n%400==0) flg = 2;

  if(flg == 2){
    if(n%100 == 0) return 0;
    return 1;
  }
  else if(flg == 1) return 1;

  return 0;
}

int main(){
  int f,e;

  while(1){
    int cnt = 0;
    cin >> f >> e;
    if(f == 0 && e == 0) break;

    for(int i = f ; i <= e ; i++){
      if(judge(i)){
        cout << i << endl;
        cnt++;
      }
    }
    if(cnt == 0) cout << "NA" << endl;
    cout << endl;
  }

  return 0;
}