def diagonal(matrix, reverse=False):
    """ Return matrix' diagonal (count from the the back if reverse = True). """
    diag = 0
    if not reverse:
        for i in range(len(matrix)):
            diag += matrix[i][i]
    else:
        for i in range(len(matrix)):
            diag += matrix[i][(len(matrix) - 1) - i] 
    return diag