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>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 bool isLeap(int year)
 {
   if(year%4!=0) return false;
   else
   {
     if(year%4==100)
     {
       if(year%4==400) return true;
       else return false;               
     }
     else return true;    
   }     
 }
 
 int main()
 {
   int start,end;
   while(cin>>start>>end&&(start||end))
   {
     int count=0;
     for(int i=start;i<=end;i++)
     {
       if(isLeap(i))
       {
         cout<<i<<endl; 
         count++;
       }        
     }                       
     if(!count) cout<<"NA"<<endl;
     cout<<endl;             
   }
   //while(1);
   return 0;
 }

C++: #include <stdio.h>

void judge_leap_year(int a, int b);

int existance_leap_year(int a, int b);

int main(void)
{
    while(1) {
      int exist;
      int start_year, end_year;
      scanf("%d %d", &start_year, &end_year);
      if (start_year == 0 && end_year == 0) {
        break;
      } else {exist = existance_leap_year(start_year, end_year);
        if (exist == 1) {
          printf("\n");
          judge_leap_year(start_year, end_year);
        } else {
          printf("NA\n");
        }
      }
      printf("\n");
    }
    return 0;
}

void judge_leap_year(int a, int b)
{
    int year;
    for (year = a; year <= b; year++) {
      if (year % 400 == 0) {
        printf("%d\n", year);
      } else if (year % 4 == 0 && year % 100 != 0) {
        printf("%d\n", year);
      }
    }
}
//閏年を記述する                                                                                                                                                                     

int existance_leap_year(int a, int b)
{
    int n = 0;
    int year;
    for (year = a; year <= b; year++) {
      if (year % 400 == 0) {
        n = 1;
        break;
      } else if (year % 4 == 0 && year % 100 != 0) {
        n = 1;
        break;//一度閏年を検出した時点でループを抜ける。                                                                                                                             
      }
    }
    return n;
}
//閏年があった時、１を返す

C++: #include <iostream>


int leap_year(int y) {
	if( y % 400 == 0) {
		return 1;/*???????????´*/
	} else if (y % 100 == 0 && y % 400 != 0) {
		return 0;/*???????????´??§??????*/
	} else if (y % 4 == 0 && y % 100 != 0) {
		return 1;
	} else {
		return 0;
	}
}
int main()
{
	int a;
	int b;
	while (true) {
		std::cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		} else {
			int sum = 0;
			for (int k = a; k <= b; k++) {
				sum = sum + leap_year(k);
			}
			if (sum == 0 /*????????????????????´?????????*/) {
				std::cout << "NA" << std::endl;
			} else {
			    for (int i =a; i <= b; i++) {
					if (leap_year(i) == 1) {
						std::cout << i << std::endl;
					}
				}
			}
			std::cout << std::endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  while(true){
    if(!a&&!b)break;
    a--;
    if (b/4-a/4-b/100+a/100+b/400-a/400){
      for(int i=a/4*4+4;i<b;i+=4)
	cout<<i<<endl;
    }
    else{
      cout<<"NA"<<endl;
    }
    cin>>a>>b;
    if(!a&&!b)break;
    cout<<endl;
  }
  return 0;
}

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

C++: #include <stdio.h>

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

int main(void)
{
    int year, from, until, num_leap_year, flag = 0;
    while (1) {
        num_leap_year = 0;
        scanf("%d %d", &from, &until);
        if (from == 0 && until == 0) {
            break;
        } else {
            if ( flag != 0) {
                printf("\n");
            }
        }
        for (year = from; year <= until; year++) {
            if (isLeapYear(year) == true) {
                num_leap_year++;
                printf("%d\n", year);
            }
        }
        if (num_leap_year == 0) {
            printf("NA\n");
        }
        flag++;
        //printf("\n");
    }
    return 0;
}

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

int main(){
	int year[3001];
	for(int i=0;i<3001;i++){
		if(i%4==0){
			year[i]=1;
		}else year[i]=0;
		if(i%100==0){
			year[i]=0;
		}
		if(i%400==0){
			year[i]=1;
		}
	}
	int a,b;
	while(1){
		cin>>a>>b;
		if(a==0 && b==0){
			break;
		}else{cout<<endl;}
		int cnt=0;
		for(int j=a;j<=b;j++){
			if(year[j]==1){
				cout<<j<<endl;
				cnt++;
			}
		}
		if(cnt==0)cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<stdio.h>

void leap_year(int start_year, int end_year);

int main(void)
{
  int start_year;
  int end_year;
    while(1){
    scanf("%d %d", &start_year, &end_year);
    if (start_year == 0 && end_year == 0) {
      break;
	} else {
    leap_year(start_year, end_year);
    printf("\n");
    }
    }
    return 0;
}

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

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;
	
	while (cin >> a >> b, a || b)
	{
		bool flag = false;
		
		for (int y=a; y<=b; y++)
		{
			if (isLeapYear(y))
			{
				cout << y << endl;
				flag = true;
			}
		}
		
		if (!flag) cout << "NA" << endl;
		cout << endl;
	}
	
	return 0;
}