f = false
while gets
  a,b = $_.split.map(&:to_i)
  puts if f && !(a == 0 && b == 0)
  f = true
  break if a == 0 and b == 0
  flag = false
  while a != b + 1
    if (a % 4 == 0) && (!(a % 100 == 0) || (a % 400 == 0))
      p a
      flag = true
    end
    a += 1
  end
  puts "NA" if !flag
end