#include <cstdio>
using namespace std;

int main() {
  int a, b, c, k;
  bool first = true;
  while (1) {
    scanf("%d %d", &a, &b);
    if (!a && !b) break;
    if (!first) puts("");
    else first = false;
    k = a;
    while (k%4) ++k;
    c = 0;
    for (; k<=b; k+=4) {
      if (k%400 && !(k%100)) continue;
      printf("%d\n", k);
      ++c;
    }
    if (!c) printf("NA\n");
  }

  return 0;
}