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 "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	auto func = [](int y){
		if(!(y%400)) return true;
		else if(!(y%100)) return false;
		else if(!(y%4)) return true;
		return false;
	};

	for(int N=0;;N++){
		int a=in(),b=in();
		if(!a && !b) break;
		if(N) out();
		int flag = false;
		for(int i=a;i<=b;i++){
			if(func(i)){
				flag = true;
				out(i);
			}
		}
		if(!flag) out("NA");
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

bool is_leap_year(int year){
	if(year % 4 == 0){
		if(year % 400 == 0){
			return true;
		}
		else if(year % 100 == 0){
			return false;
		}
		else{
			return true;
		}
	}

	return false;
}


int main(int argc, char **argv){
	int a, b;
	bool is_first = true;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> a >> b){
#else
	while(std::cin >> a >> b){
#endif
		if(a == 0 && b == 0){ break; }
		if(is_first){
			is_first = false;
		}
		else{
			std::cout << std::endl;
		}
		std::vector<int> leap_years;

		for(int i = a; i <= b; i++){
			if(is_leap_year(i)){
				leap_years.push_back(i);
			}
		}

		if(leap_years.empty()){
			std::cout << "NA" << std::endl;
		}
		else{
			for(int i = 0; i < leap_years.size(); i++){
				std::cout << leap_years[i] << std::endl;
			}
		}
	}

 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstring;
typedef pair<int, int> pint;
typedef pair<pint, int> ppint;
typedef pair<int, pint> pintp;
typedef unsigned int uint;
typedef long long llint;
typedef unsigned long long int ullint;

//container util
//------------------------------------------
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find((v).begin(), (v).end(), i) != (v).end())
#define ERASE(v,i) (v).erase(remove((v).begin(),(v).end(),i),(v).end())
#define me (*this)

//repetition
//------------------------------------------
#define rep(i,s) for(int i=0; i<(int)(s); i++)

//constant
//--------------------------------------------
const int INF = 100000000;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLEAR(a) memset((a), 0 ,sizeof(a))

//debug
#define debug(x)  cerr << #x << " = " << (x) << endl

struct POS {
	int x, y;
};

POS vec[4] = {
	{1, 0}, // ツ右
	{0, -1}, // ツ湘」
	{-1, 0}, // ツ債カ
	{0, 1} // ツ可コ
};

bool leapYear(uint year) {
	if(year % 4)
		return false;
	if(year % 400)
		return true;
	if(year % 100)
		return false;
	return true;
}

int main() {
	while(true) {
		static int p, q;
		cin >> p >> q;
		if(!p && !q)
			break;
		vint year;
		for(; p <= q; p++) {
			if(leapYear(p)) {
				year.pb(p);
			}
		}
		if(year.size() == 0) {
			puts("NA");
		} else {
			for(vint::iterator itr = year.begin(); itr != year.end(); itr++)
				cout << *itr << endl;
		}
		printf("\n");
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int i,a,b,w,x,flg;
	scanf("%d %d",&a,&b);
	while(!(a==0 && b==0)){
		w=0;
		flg=0;
		for(i=a;i<=b;i++){
			w=a%4;
			if(a%100!=0){
				if(w==0 || a%400==0){
					printf("%d\n",a);
					flg=1;
				}
			}
			a++;
		}
		
		if(flg==0){
			printf("NA\n");
		}
		scanf("%d %d",&a,&b);
		printf("\n");
	}
	return 0;
}

C++: 
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  int b,e;
  bool fa=false;
  while(cin >> b >> e , b+e){
    if(fa)cout<<endl;
    bool na=false;
    loop(i,b,e){
      if(i%400==0){
	cout<< i << endl;
      }
      if(i%100 && i%4==0){
	cout<<i<<endl;
	na=true;
      }
    }
    if(!na)cout<<"NA"<<endl;
    cout<<endl;
  }

}

C++: #include <iostream>

using namespace std;

int main(){
	int a,b;
	int line =0;
	while(cin >> a >> b){
		if(a==0 && b==0) break;
		int count=0;
		if(line !=0) cout << "\n"; line++; 
		for(int i=a; i < b; i++){
			if(i % 4==0 && i%100 !=0 || i % 400 ==0) {
				cout << i << "\n";
				count++;
			} 
		}
		if(count==0) cout << "NA\n";
		
	}

	return 0;
}

C++: #include <iostream>

bool judge_uruyear(int year)
{

    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }

}

void print_uruyear(int year_begin, int year_end)
{

    int count_year = 0;

    std::cout << std::endl;

    // kono for loop no jyouken-siki ha "=" hituyou!
    for (int i = year_begin; i <= year_end; i++) {
        if (judge_uruyear(i)) {
            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if (count_year == 0) { 
        std::cout << "NA" << std::endl;
    }

    //std::cout << std::endl;

}

int main()
{

    int year_begin, year_end;

    while (true) {
        
        std::cin >> year_begin >> year_end;

        if (year_begin == 0 && year_end == 0) {
            break;
        }
        
        print_uruyear(year_begin, year_end);

    }
    
    return 0;
}