import std.stdio, std.format, std.string, std.conv;

void main()
{
  int[] hVals = new int[]( 150_0001 );
  int[] wVals = new int[]( 150_0001 );
  
  while ( true ) {
	int n, m;
	string input = readln;
	formattedRead( input, "%d %d\n", &n, &m );
	if ( n == 0 && m == 0 ) break;

	int[] hs = new int[]( n );
	foreach ( i; 0 .. n ) {
	  hs[ i ] = to!int( strip( readln ) );
	}
	int[] ws = new int[]( m );
	foreach ( i; 0 .. m ) {
	  ws[ i ] = to!int( strip( readln ) );
	}

	collect( hVals, hs );
	collect( wVals, ws );
	int ans = 0;
	foreach ( i; 1 .. 150_0001 ) {
	  ans += hVals[ i ] * wVals[ i ];
	}
	writeln( ans );
  }
}

void collect( int[] vals, int[] vs ) {
  vals[] = 0;
  foreach ( i; 0 .. vs.length ) {
	int sum = 0;
	foreach ( v; vs[ i .. $ ] ) {
	  sum += v;
	  vals[ sum ]++;
	}
  }
}