#include<iostream>
using namespace std;
int main(){
  int a, b, k = 0;
  while(cin >> a >> b, a||b){
    if(k > 0 and (a or b)) cout << endl;
    int t = 0;
    ++k;
    for(int i = a; i <= b; ++i){
      if(i%4) continue;
      if((not (i%100)) and i%400) continue;
      ++t;
      cout << i << endl;
    }
    if(not t) cout << "NA" << endl;
  }
}

