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;
}

