Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func isLeapYear(y int) bool {
	return (y%4 == 0 && y%100 > 0) || (y%4 == 0 && y%400 == 0)
}

func cntLeap(y []int) {
	cnt := 0

	for i := y[0]; i <= y[1]; i++ {
		if isLeapYear(i) {
			cnt++
			fmt.Println(i)
		}
	}

	if cnt == 0 {
		fmt.Println("NA")
	}
}

func main() {
	num := 0

	for sc.Scan() {
		y := Sliceconvtoi()

		if y[0] == 0 && y[1] == 0 {
			break
		}

		if num > 0 {
			fmt.Println()
		}

		cntLeap(y)
		num++
	}

}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }





int main() {
	int a, b;
	
	while (1) {
		cin >> a >> b; if (a==0 && b==0) break;
		
		bool flag = false;
		for_(i, a, b+1) {
			if (i%100==0) {
				if (i%400==0) {
					cout << i << endl;
					flag = true;
				}
			} else if (i%4==0) {
				cout << i << endl;
				flag = true;
			}
		}
		if (!flag) cout << "NA" << endl;
		cout << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main(void){

    int a,b;
    int f;

    while (true) {

        scanf("%d %d",&a,&b);

        if (a == 0 && b == 0) {
            return 0;
        }
        f = 0;

        for (int i = 0; i < (b-a+1) ; i++) {
            if ((a+i)%4 == 0) {
                if ((a+i)%100 == 0) {
                    if ((a+i)%400 == 0) {
                        cout << a+i << endl;
                        f = 1;
                    }
                    //no
                }
                else {
                    cout << a+i << endl;
                    f = 1;
                }
            }
            else {
                //no
            }


        }

        if (f == 0) {
            cout << "NA" << endl;
        }

        cout << endl;                                                            

    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int y[3001];

int main()
{
  for (int i = 4; i <= 3000; i += 4){
    y[i] = 1;
  }
  for (int i = 100; i <= 3000; i += 100){
    y[i] = 0;
  }
  for (int i = 400; i <= 3000; i += 400){
    y[i] = 1;
  }
  
  int a, b;
  while (1){
    cin >> a >> b;
    if (a == 0){
      break;
    }
    int c = 0;
    for (int i = a; i <= b; i++){
      if (y[i] == 1){
        cout << i << endl;
        c = 1;
      }
    }
    if (c == 0){
      cout << "NA" << endl;
    }
  cout << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main(void)
{
  int a, b;
  vector <int> hoge, leap;

  while (1) {
    cin  >> a >> b;
    if (a == 0 && b == 0)
      break;
    hoge.push_back(a);
    hoge.push_back(b);
  }
  for (int i = 0; i < hoge.size(); i += 2) {
    for (int j = hoge[i]; j <= hoge[i+1]; j++)
      if (j % 400 == 0 || (j % 100 && j % 4 == 0))
        leap.push_back(j);
    if (!leap.empty()) {
      for (int j = 0; j < leap.size(); j++)
        cout << leap[j] << endl;
      leap.erase(leap.begin(), leap.end());
    } else {
      cout << "NA" << endl;
    }
    cout << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int a,b,x;
vector<int> leaps(3000,0);

void FilterLeap(){
  rep(i,3000){
    if((i+1) % 400 == 0 ||( (i+1) % 4 == 0 && (i+1)%100 != 0)){
      leaps[i+1] = 1;
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FilterLeap();
  while(cin >> a >> b){
    if(a + b == 0) break;
    x = 0;
    for(int i = a; i <=b ;++i){
      if(leaps[i] == 1){
        cout << i << endl;
      }
      else{
        ++x;
      }
    }
    if(x == b-a+1){
      cout << "NA" << endl;
    }
  }
  return 0;
}