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>

using namespace std;

int main(void){

  int a,b;
  while( cin >> a >> b ){

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

    bool flag = false;
    for( int i = a ; i <= b ; i++ ){
      if( i % 4 == 0 ){
	if( i % 400 == 0 ) cout << i << endl;
	else if( i % 100 == 0 ) continue;
	else cout << i << endl;
	flag = true;
      }
    }
    if(flag) cout << endl;
    else cout << "NA" << endl << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;


const double EPS = 1e-9;

static bool uruu[3000];

int main(){
	for(int i = 0; i < 3000; i+=4){
		uruu[i] = true;
	}
	for(int i = 0; i < 3000; i+=100){
		uruu[i] = false;
	}
	for(int i = 0; i < 3000; i+=400){
		uruu[i] = true;
	}
	

	int a, b;
	bool f = true;
	while(cin >> a >> b, b){
		if(!f){
			cout << endl;
		}
		f = false;
		bool na = true;
		for(int i = a; i <= b; i++){
			if(uruu[i]){
				cout << i << endl;
				na = false;
			}
		}
		if(na){
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include <stdio.h>

void leap_year(int year);
int leap_year_judge(int year_a, int year_b);

int main(void)
{
	int year_a, year_b, exist;
	while (1) {
		scanf("%d %d", &year_a, &year_b);
		exist = leap_year_judge(year_a, year_b);
		if (year_a == 0 && year_b == 0){
			break;
		} else if (exist == 1){
			printf("\n");
			for (int i = year_a; i <= year_b; i++) {
				leap_year(i);
			}
		} else {
			printf("\nNA\n");
		}
	}
	return 0;
}

void leap_year(int year)
{
	if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
		printf("%d\n", year);
	} 
}

int leap_year_judge(int year_a, int year_b)
{
	int judge = 0;
	for (int i = year_a; i <= year_b; i++) {
		if (i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)) {
			judge = 1;
		} 
	}
	return judge;
}

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

int main() {
	int a, b;
	bool first = true;
	for (cin >> a >> b; a && b; cin >> a >> b) {
		if (first) {
			first = !first;
		}
		else {
			cout << endl;
		}
		vector<int> years;
		int i;
		for (i = a + 1; i < b; ++i) {
			if (i % 400 == 0 || (i % 4 == 0 && i % 100)) {
				years.push_back(i);
				break;
			}
		}
		for (i += 4; i < b; i += 4) {
			if (i % 100 || i % 400 == 0) {
				years.push_back(i);
			}
		}
		if (years.empty()) {
			cout << "NA" << endl;
		}
		else {
			for (int i = 0; i < years.size(); ++i) {
				cout << years[i] << endl;
			}
		}
	}
	return 0;
}

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

bool isLeapYear(int y) {
  if(!(y % 4)) {
    if(!(y % 100)) {
      if(!(y % 400)) return true;
      return false;
    }
    return true;
  }
  else return false;
}

int a[50], b[50];

int main() {
  int n = 0;
  bool flag;
  while(cin >> a[n] >> b[n]) {
    if(a[n] == 0 && b[n] == 0) break;
    n++;
  }

  for(int j = 0; j < n; ++j) {
    flag = 0;
    for(int i = a[j]; i <= b[j]; ++i) {
      if(isLeapYear(i)) {
        flag = 1;
        cout << i << endl;
      }
    }
    if(!flag) cout << "NA" << endl;
    if(j < n - 1) cout << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  if(fi) fi = false;
  else
    cout << endl;

  FOR(i,a,b+1){
    if(i % 4 == 0){
      if(i % 100 == 0){
        if(i % 400 == 0){
          cout << i << endl;
          f = true;
        }
        
      }else{
        cout << i << endl;
        f = true;
      }
    }
  }

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

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

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

C++: #include <iostream>

using namespace std;

int main(){

	int a,b;

	while(1){

		int count = 0;

		cin >> a >> b;
		if(a == 0 && b == 0) break;

		for(int i = a; i <= b; i++){

			if(i % 4 == 0 && i % 100 != 0 || i % 400 == 0){
				cout << i << endl;
				count++;
			}

		}

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

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n, m;
  bool f = true;
  while(cin >> n >> m){
    if( n == 0||m==0 ) break;
    if(!f ) cout << endl;
    f = false;
    vector<int> ans;
    for(int i=n; i<=m; i++){
      if( i % 400 == 0) ans.push_back(i);
      else if( i % 100 == 0 ) continue;
      else if( i % 4 == 0 ) ans.push_back(i);
    }
    if( ans.size() == 0 ) cout << "NA" << endl;
    else for(int i=0; i<ans.size(); i++) cout << ans[i] << endl;

  }


  return 0;
}


// EOF