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++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//うるう年判定
bool isLeap(int y) {
	bool flag = false;
	if (y % 4 == 0)flag = true;
	if (y % 100 == 0)flag = false;
	if (y % 400 == 0)flag = true;
	return flag;
}

int main() {
	bool first = true;

	while (true) {
		int a, b; cin >> a >> b;
		if (a == 0 && b == 0)break;

		if (!first)puts("");

		bool flag = false;
		FOR(i, a, b + 1)if (isLeap(i)) {
			flag = true;
			Cout(i);
		}
		if (!flag)puts("NA");

		first = false;
	}
}

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

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


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


int main()
{
	int a, b;
	bool first_flag = true;
	
	while (cin >> a >> b, a || b)
	{
		if (first_flag)
		{
			first_flag = false;
		} else {
			cout << endl;
		}
		
		bool flag = false;
		
		for (int y=a; y<=b; y++)
		{
			if (isLeapYear(y))
			{
				cout << y << endl;
				flag = true;
			}
		}
		
		if (!flag) cout << "NA" << endl;
	}
	
	return 0;
}

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

int main(){
	int a,b;
	bool first=true;
	while(cin>>a>>b,a||b){
		bool f=false;
		if(!first)cout<<endl;
		if(a&3)a+=4-(a&3);
		while(a<=b){
			if(a%100 || a%400==0){
				f=true;
				cout<<a<<endl;
			}
			a+=4;
		}
		if(!f)cout<<"NA"<<endl;
		first=false;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define p(dis) cout << dis << endl

int func(int a, int b){
	int f = 1;
	for(int i = a;i <= b;i++){
		if(i % 4 == 0){
			if(i % 100 == 0){
				if(i % 400 == 0)p(i), f = 0;
				continue;
			}
			p(i), f = 0;
		}
	}
	return f;
}

int main(){
	int a = 1, b;
	while(cin >> a >> b, a+b){
		if(func(a, b))cout << "NA" <<endl;
	}
	return 0;
}

C++: #pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {

    bool first = true;

    while (true) {
        
        ll a, b; cin >> a >> b;
        if (!a && !b) break;

        if (!first) cout << "\n";
        first = false;

        bool exist = false;
        RANGE(i, a, b) {
            if (i % 4 == 0 && (i % 100 || i % 400 == 0)) {
                cout << i << endl;
                exist = true;
            }
        }

        if (!exist) {
            cout << "NA\n";
        }

    }
    
}

C++: #include <stdio.h>

int count_number(void);

int main(void)
{
    
    int a[15];//15は適当　要素数はわからないが配列を作りたかった
    int b[15];
    int dataset_number = 0;
    while (1) {
        scanf("%d %d", &a[dataset_number], &b[dataset_number]);
        if (a[dataset_number] == 0 && b[dataset_number] == 0) {
            break;
        }
        dataset_number++;
    }
    int j = 0;
    while(j < dataset_number-1){
        int leapyear_number = 0;
        int i = a[j];
        while (i <= b[j]) {
            if ((((i % 4) == 0) && ((i % 100) != 0)) || ((i % 400) == 0)) {
                printf("%d\n", i);
                leapyear_number++;
            }
            i++;
        }
        if (leapyear_number == 0){
            printf("NA\n\n");
        } else {
            printf("\n");
        }
        j++;    
    }
    //j=dataset_number-1の時のみ最後\がひとつ
    if(dataset_number > 0){
        int leapyear_number = 0;
        int i = a[dataset_number-1];
        while (i <= b[dataset_number-1]) {
            if ((((i % 4) == 0) && ((i % 100) != 0)) || ((i % 400) == 0)) {
                printf("%d\n", i);
                leapyear_number++;
            }
            i++;
        }
        if (leapyear_number == 0){
            printf("NA\n");
        } else {
            
        }
    }
}

C++: #include<stdio.h>
int main(){
int years[3001]={0},a,b,c,f=0;
for(int i=0;i<3000;i++){
	if(i%4==0){
		if(i%100==0 && i%400==0){
			years[i]=1;
		}else if(i%100!=0){
			years[i]=1;
		}
	}
}	
while(1){
	scanf("%d %d",&a,&b);
	if(a==0 && b==0) break;
	f==0?f=1:printf("\n");
	c=0;
	a+=(a%4==0?0:4-a%4);
	for(int i=a;i<=b;i+=4){
		if(years[i]==1){
			printf("%d\n",i);
			c++;
		}
	}
	printf("%s",c==0?"NA\n":"");
}
}