def K(A,L=None):
    """ 
    Function we are trying to maximize: sum_{i<j} A[L[i]][L[j]]
    A is m x m matrix, 
    L is a subset of range(m) (or defaults to range(m) if no L given)
    """
    if L==None:
        L = range(len(A))
    return sum([A[L[i]][L[j]] for j in range(len(L)) for i in range(j)])