x = gets
y = x.split(" ")
a = y[0].to_i
b = y[1].to_i
until a == 0 && b == 0
 sss = []
 for i in a..b do 
  if i % 4 == 0
   if i % 100 == 0
     if i % 400 == 0
      sss << i 
     end
   else
    sss << i 
   end
  end
 end
 if sss.length == 0
  puts "NA"
 else
  sss.each do |n|
   puts n
  end
 end
 
 x = gets
 y = x.split(" ")
 a = y[0].to_i
 b = y[1].to_i
 if a == 0 && b == 0
 else
  puts ""
 end
end
