loop do
  n,m = gets.split.map(&:to_i)
  exit if n == 0 and m == 0
  hs = n.times.map{gets.to_i}
  ws = m.times.map{gets.to_i}
  hcount = Hash.new(0)
  hss = hs.inject([0]){|s,i| x = s.last + i; hcount[x] += 1; s << x}[1..-1]
  (0...hs.length).each do |i|
    hss = hss[1..-1].map{|x| x = x - hs[i]; hcount[x] += 1; x}
  end

  wcount = Hash.new(0)
  wss = ws.inject([0]){|s,i| x = s.last + i; wcount[x] += 1; s << x}[1..-1]
  (0...ws.length).each do |i|
    wss = wss[1..-1].map{|x| x = x - ws[i]; wcount[x] += 1; x}
  end
  puts 1.upto(hs.inject(:+)).inject(0){|s,x| s += hcount[x] * wcount[x]}
end