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;
    for(int i=0; i < 55; i++){
      cin >> a >> b;
      if(a==0 && b==0){
          break;
      }
      if(i != 0){
          cout << endl;
      }
      if(a%4 == 0){
          if(a+4 <= b){
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                  if(a%400 != 0 && a%100 == 0){
                    a += 4;
                  }else{
                  cout << a << endl;
                  a+=4;
                  }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 1){
          if(a+3 <= b){
              a += 3;
              int c;
              c= b-a;
              for(int j=0; j <= c/4 ; j++){
                if(a%400 != 0 && a%100 == 0){
                    a+=4;
                }else{
                cout << a << endl;
                a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 2){
          if(a+2 <= b){
              a += 2;
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                if(a%400 != 0 && a%100 == 0){
                    a+=4;
                }else{
                cout << a << endl;
                a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 3){
          if(a+1 <= b){
              a += 1;
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                if(a%400 != 0 && a%100 == 0){
                    a+=4;
                }else{
                cout << a << endl;
                a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
    }
}

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

int main()
{
	int a, b;
	bool first = true;

	while (scanf("%d%d", &a, &b), a){
		if (!first){
			printf("\n");
		}

		first = false;

		bool na = true;
		for (int i = a; i <= b; i++){
			if (i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)){
				printf("%d\n", i);
				na = false;
			}
		}

		if (na){
			printf("NA\n");
		}
	}

	return (0);
}

C++: #include<iostream>

using namespace std;

int main()
{
	int a,b;
	int year[4096];
	int i;
	
	for(i=0;i<3001;i++)
	{
		if((i%4==0 && i%100!=0) || i%400==0)
			year[i]=1;
		else
			year[i]=0;
	}
	int flag=0;
	for(;;)
	{
		cin >> a >> b ;
		if(a==0 && b==0)
			break;
		
		if(flag==1)
			cout << endl;
		flag=1;
		int flag2=0;
		for(i=a;i<=b;i++)
		{
			if(year[i]==1)
			{
				flag2=1;
				cout << i << endl;
			}
		}
		if(flag2!=1)
			cout << "NA" << endl;
	}
}

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

int main(){
	int a,b,count=0;
	while(1){
		cin>>a>>b;
		if(a==0 && b==0){
			break;
		}
		while(a<=b){
			if(a%4==0){
				if(a%100==0){
					if(a%400==0){
						cout<<a<<endl;
						count++;
					}
				}else{
					cout<<a<<endl;
					count++;
				}
			}
			a++;
		}
		if(count==0){
			cout<<"NA"<<endl;
		}
		count=0;
	}
	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr bool isLeapYear(const int &y) {
  return y % 400 == 0 || (y % 4 == 0 && y % 100 != 0);
}

void solve() {
  vvi vv;
  int a, b;
  while (cin >> a >> b, a) {
    vi v;
    for (int x = a; x <= b; x++) {
      if (isLeapYear(x)) v.pb(x);
    }
    vv.pb(v);
  }
  if (vv.size()) {
    if (vv[0].size()) {
      cout << vv[0][0] << endl;
      loop(j, 1, vv[0].size()) cout << vv[0][j] << endl;
    } else {
      cout << "NA" << endl;
    }
    loop(i, 1, vv.size()) {
      cout << endl;
      if (vv[i].size()) {
        cout << vv[i][0] << endl;
        loop(j, 1, vv[i].size()) cout << vv[i][j] << endl;
      } else {
        cout << "NA" << endl;
      }
    }
  }
}

C++: #include <bits/stdc++.h>

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

/*int main() {
  string a;
  cin >> a;
  string s = "";
  for (int i = 0; i < 10; i++) {
    s += a[i];
  }
  for (int i = 0; i < 44; i++) {
    int t = s[0 + i] - '0';
    int u = s[1 + i] - '0';
    s += (t + u) % 10 + '0';
  }
  cout << s[54] << endl;
  return 0;
}*/
int a, b;
while (cin >> a >> b && a != 0 && b != 0) {
  int p = 1;
  if (p) {
    cout << endl;
    p = 0;
  }
  int flag = 1;
  for (int i = a; i <= b; i++) {
    if (i % 100 == 0 && i % 400 != 0) {
      // continue;
    } else if (i % 4 == 0 && i % 100 != 0) {
      cout << i << endl;
      flag = 0;
    } else if (i % 400 == 0) {
      cout << i << endl;
      flag = 0;
    } else {
      // continue;
    }
  }
  if (flag) {
    cout << "NA" << endl;
  }
}
return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  int a, b;
  vector<int> ans;
  vector<int> count;
  while(cin >> a >> b, a, b){
    int cnt = 0;
    for(int i = a; i <= b; i++){
      if(i % 4 == 0){
        if(i % 100 != 0 || i % 400 == 0){
          ans.push_back(i);
          cnt++;
        }
      }
    }
    count.push_back(cnt);
  }
  int l = 0, k = 0;
  for(int i = 0; i < ans.size(); i++){
    if(count[k] == 0){
      cout << "NA" << endl;
      i--;
    }else{
      cout << ans[i] << endl;
      l++;
    }
    if(l == count[k] && i != ans.size() - 1){
      cout << endl;
      k++;
      l = 0;
    }
  }
}