def multiply(self, a, b):
if a is None or b is None: return None<EOL>m, n = len(a), len(b[<NUM_LIT:0>])<EOL>if len(b) != n:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>l = len(b[<NUM_LIT:0>])<EOL>table_a, table_b = {}, {}<EOL>for i, row in enumerate(a):<EOL><INDENT>for j, ele in enumerate(row):<EOL><INDENT>if ele:<EOL><INDENT>if i not in table_a: table_a[i] = {}<EOL>table_a[i][j] = ele<EOL><DEDENT><DEDENT><DEDENT>for i, row in enumerate(b):<EOL><INDENT>for j, ele in enumerate(row):<EOL><INDENT>if ele:<EOL><INDENT>if i not in table_b: table_b[i] = {}<EOL>table_b[i][j] = ele<EOL><DEDENT><DEDENT><DEDENT>c = [[<NUM_LIT:0> for j in range(l)] for i in range(m)]<EOL>for i in table_a:<EOL><INDENT>for k in table_a[i]:<EOL><INDENT>if k not in table_b: continue<EOL>for j in table_b[k]:<EOL><INDENT>c[i][j] += table_a[i][k] * table_b[k][j]<EOL><DEDENT><DEDENT><DEDENT>return c<EOL>
:type A: List[List[int]]
:type B: List[List[int]]
:rtype: List[List[int]]