#include<iostream>
using namespace std;

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

int main(){
  int a,b;
  bool line=false;
  while(cin >> a >> b, a||b){
    if(line)cout << endl;
    line = true;

    bool f=false;
    for(int i=a;i<=b;i++)
      if(isLeap(i)){
	cout << i << endl;
	f=true;
      }
    if(!f)cout << "NA\n";
  }
}