### Main Idea:

The `k`

th smallest element must be in the upper left region, because rows and columns are sorted in ascending order. Then we add possible elements to a list, in which the `k`

th smallest element is the answer.

### Code:

```
class Solution(object):
def kthSmallest(self, matrix, k):
res=[]
res+=[matrix[i][j] for i in xrange(0,len(matrix)) for j in xrange(0,len(matrix)) if (i+1)*(j+1)<=k]
return sorted(res)[k-1]
```