def prod(A, B):
    """ Returns the matrix product of two matrices using lists
    """

    # Check if dimenstions are compatible
    if len(A[0]) != len(B):
        raise ValueError("Dimensions do not match.")

    product = []
    # iterate through rows of A
    for i in range(len(A)):
        # new row for final product
        new_row = []
        # iterate through columns of B
        for j in range(len(B[0])):
            new_row.append(0)
            # iterate through rows of B
            for k in range(len(B)):
                new_row[-1] += A[i][k] * B[k][j]
        # append row to final product
        product.append(new_row)

    return product