human
I found an interesting problem on https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/:
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.

Note that it is the kth smallest element in the sorted order, not the kth distinct element.

Example:

matrix = [
   [ 1,  5,  9],
   [10, 11, 13],
   [12, 13, 15]
],
k = 8,

return 13.


Note: 
You may assume k is always valid, 1 ≤ k ≤ n2.

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is Python program to find the kth smallest element in the matrix.

class Solution:
     def kthSmallest(self, matrix, k):
         """
         :type matrix: List[List[int]]
         :type k: int
         :rtype: int
         """
         from heapq import heappush, heappop
         n = len(matrix[0])
         heap = []
         for i in range(n):
             heappush(heap, (matrix[0][i], 0, i))
         for _ in range(k-1):
             v, x, y= heappop(heap)
             if x == n - 1:
                 continue
             heappush(heap, (matrix[x+1][y], x+1, y))
         return heappop(heap)[0]