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++: #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>

void leap_year(int start, int end)
{
    int y = 0;
    for (int x = start; x <= end; ++x) {
        if (x % 4 == 0 && (x % 100 != 0 || x % 400 == 0)) {
            printf("%d\n", x);
            ++y;
        }
    }
    if (y == 0) {
        printf("NA\n");
    }
}
        
int main(void)
{
    while (1) {
        int start, end;
        scanf("%d %d", &start, &end);
        if (start == 0 && end == 0) {
            printf("\n");
        } else {
            leap_year(start, end);
            printf("\n");
        }
    }
    return 0;
}

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

int main(){
    int a, b;
    int leap;

    while(1){
        leap = 0;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        for(int y = a; y<=b; y++){
            if(y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)){
                leap++;
                cout << y << endl;
            }
        }

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

    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int start = 0, end = 0;
    cin >> start >> end;
    while(1) {
        bool flag = false;
        for(int i = start; i <= end; i++) {
            if (i % 4  == 0 && (i % 100 != 0 || i % 400 == 0)) {
                flag = true;
                cout << i << endl;
            }
        }
        if (!flag) {
            cout << "NA" << endl;
        }
        cin >> start >> end;
        if (!start && !end) return 0;
        cout << endl;
    }
}

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

int main(){
	int a, b;

	while( cin >> a >> b && !( a == 0 && b == 0 ) ){
		bool exist = false;
		for( int i = a + ( 4 - a%4 ) % 4; i <= b; i += 4 ){
			exist = true;
			if( i % 400 != 0 && i % 100 == 0 ){
				continue;
			}
			cout << i << endl;
		}
		if( !exist ){
			cout << "NA" << endl;
		}
		cout << endl;
	}

	return 0;
}

C++: #include <stdio.h>

int j = 0;

void uru(int year);

int main(void)
{
    int a, b;
    int year;
    while (1) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) {
            break;
        } else  {
            for (year = a; year <= b; ++year) {
                uru(year);
            }            
            if (j == 0) {
                printf("NA\n");
            }
        }
        printf("\n");
    }
    return 0;
}

void uru(int year)
{
    int R4, R100, R400;
    R4 = year % 4;
    R100 = year % 100;
    R400 = year % 400;
    if (R4 == 0 && R100 != 0) {
        printf("%d\n", year);
        ++j;
    } else if (R400 == 0) {
        printf("%d\n", year);
        ++j;
    }
}

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

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

C++: #include <stdio.h>

int main(){

	int a,b;
	int i;
	int answer[1000];
	int count;

	while(1){

		count = 0;

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

		if(a == 0 && b == 0){
			break;
		}

		for(i = a; i < b; i++){
			if( i % 400 == 0 || i % 100 !=0 && i % 4 == 0){
				answer[count] = i;
				count ++;
			}
		}

		for(i = 0; i < count; i++){
			printf("%d\n",answer[i]);
		}

		if(count == 0){
			printf("NA");
		}
	}

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	bool leap[3000];
	rep(i, 3000) {
		if (i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)) leap[i] = true;
		else leap[i] = false;
	}
	int nCase = 0;
	for (int a, b; cin >> a >> b, (a | b) != 0; ) {
		if (nCase) cout << endl;
		bool exist = false;
		REP(i, a, b) {
			if (leap[i]) {
				cout << i << endl;
				exist = true;
			}
		}
		if (!exist) cout << "NA" << endl;
		nCase++;
	}
	
	return 0;
}