function isLeapYear(y) {
  return y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0);
}

function main() {
  var
  i,
  a, b, line,
  leaps,
  len = input.length;
  for(i = 0; i < len; i++) {
/*    if(i !== 0) {
      console.log('');
    }*/
    line = input[i].split(' ').map(parseFloat);
    a = line[0]; b = line[1];
    if(a === 0 && b === 0) break;
    leaps = [];
    for(; a < b; a++) {
      if(isLeapYear(a)) leaps.push(a);
    }
    console.log(leaps.length ? leaps.join('\n') : 'NA');
    console.log('');
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});