def findMatchSets(A):
    B = A.transpose()
pairs = tuple(combinations(list(range(len(A[0]))), 2))
matchSets = [[i for i in pairs if B[0][i[0]] + B[0][i[1]] == z] for z in
    range(3)]
for c in range(1, len(A[0])):
    matchSets = [[i for i in block if B[c][i[0]] + B[c][i[1]] == z] for z in
        range(3) for block in matchSets]
matchSets = [block for block in matchSets if len(block) > 1]
if not matchSets:
    return []
return matchSets
Найдите две пары пар, которые в сумме дают одно и то же значение