#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

bool is_uruu(int y){
  return (!(y % 4) && ((y % 100) || !(y % 400)));
}

int main() {
  int A, B;
  bool fir = true;
  while(cin >>A >>B && (A || B)){
    if(!fir) cout <<endl;
    fir = false;
    bool f = false;
    FOR(i, A, B + 1){
      if(is_uruu(i)){ f = true; cout <<i <<endl; }
    }
    if(!f) cout <<"NA" <<endl;
  }
  return 0;
}