import itertools
import numpy as np

# Function to check if the array satisfies the conditions
def is_valid_array(arr):
    for row in arr:
        if sum(row) != 0:
            return False
    for col in np.transpose(arr):
        if sum(col) != 0:
            return False
    return True

# Generate all possible combinations for a 6x6 array with 3 ones and 3 negative ones in each row
count = 0
for row1 in itertools.combinations(range(36), 3):
    for row2 in itertools.combinations(set(range(36)) - set(row1), 3):
        for row3 in itertools.combinations(set(range(36)) - set(row1) - set(row2), 3):
            for row4 in itertools.combinations(set(range(36)) - set(row1) - set(row2) - set(row3), 3):
                for row5 in itertools.combinations(set(range(36)) - set(row1) - set(row2) - set(row3) - set(row4), 3):
                    row6 = set(range(36)) - set(row1) - set(row2) - set(row3) - set(row4) - set(row5)
                    arr = np.zeros(36, dtype=int)
                    for idx in row1:
                        arr[idx] = 1
                    for idx in row2:
                        arr[idx] = 1
                    for idx in row3:
                        arr[idx] = 1
                    for idx in row4:
                        arr[idx] = 1
                    for idx in row5:
                        arr[idx] = 1
                    for idx in row6:
                        arr[idx] = -1
                    arr = arr.reshape(6, 6)
                    if is_valid_array(arr):
                        count += 1

print(count)