x=require('fs').readFileSync('/dev/stdin','utf8').split(/\s/);
i=0;
j=0;
count=0;
for(;j<x.length;j++){
    for(y=x[i++];y<=x[i];){
       if(y % 400 == 0 || (y % 100 != 0 && y % 4 == 0)){
           console.log(y);
           count++;
       }
    }
    if(count==0){
        consol.log("NA");
    }
}