def METHOD_NAME(matrix):
    # List to store the sizes of rivers
    sizes = []
    # Create a visited matrix to keep track of visited nodes
    visited = [[False for _ in range(len(matrix[0]))] for _ in range(len(matrix))]
    # Iterate over each cell in the matrix
    for i in range(len(matrix)):
        for j in range(len(matrix[i])):
            # If the cell has already been visited, continue to the next iteration
            if visited[i][j]:
                continue
            # Explore the river connected to the current cell and update sizes
            sizes = traverseNode(i, j, matrix, visited, sizes)
    return sizes