def restrict(candidates, indices, values):
    """ Restrict the fields with index in indices to the values in values, 
        remove the values from the other fields"""
    
    for i, cand in enumerate(candidates):
        if i in indices:
            candidates[i] = sorted([x for x in cand if x in values])
        else:
            candidates[i] = sorted([x for x in cand if x not in values])

    return candidates