#include <iostream>
using namespace std;

int main() {

  int a,b;
  bool kai = false;

  while(true) {

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

    if ( kai ) cout << endl;
    kai = true;

    bool flag = true;

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

      bool f = false;
      if ( i % 4 == 0 ) f = true;
      if ( i % 100 == 0 ) f = false;
      if ( i % 400 == 0 ) f = true;

      if ( f ) {
	cout << i << endl;
	flag = false;
      }

    }

    if ( flag ) cout << "NA" << endl;

  }

  return 0;

}