#include <iostream>
using namespace std;

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

int main(){
  int a, b;

  for(int SET = 1; cin >> a >> b, a || b; SET++){
    if(SET != 1){
      cout << endl;
    }

    bool ans = false;

    for(int i = a; i <= b; i++){
      if(leap(i)){
        cout << i << endl;
        ans = true;
      }
    }

    if(!ans) cout << "NA\n";
  }
}