STDOUT.sync = true
def isLeapYear?(y)
  if y%4==0&&y%100!=0
    true
  elsif y%400==0
    true
  else
    false
  end
end
c=0
while line = gets do
  a,b = line.split.map(&:to_i)
  if (a|b)==0
    break
  end
  if c!=0 then puts end 
  flag = true
  a.upto(b){|y|
    if isLeapYear?(y)
      puts y
      flag = false
    end
  }
  if flag
    puts "NA"
  end
  c+=1
end