def operate(matrices, operator):
    """
    matrices: Set of matrices of size nxn.
    operator: Either addition (+) or subtraction (-).
    Returns the resulting matrix after sum or sub.
    """
    n = len(matrices[0])
    r = matrices[0]
    for m in range(1, n):
        for i in range(n):
            for j in range(n):
                r[i][j] = operator(r[i][j], matrices[m][i][j])
    return r