def submatrix(M, row, col):
    """
    Compute the matrix obtained from M by removing the row-th row and the col-th column.
    This submatrix is then useful for computing the determinant and adjugate matrix of M.

    Input:
    M           A matrix
    row         The index of the row to remove
    col         The index of the column to remove

    Output:
    rep         A submatrx

    Format:     Any
    """
    nrow = len(M)
    ncol = len(M[0])
    rep = [[M[i][j] for j in range(ncol) if j != col] for i in range(nrow) if i != row]
    return rep