```
class Solution(object):
def kthSmallest(self, matrix, k):
"""
:type matrix: List[List[int]]
:type k: int
:rtype: int
"""
n = len(matrix)
s = []
for i in range(n):
for j in range(n):
s.append(matrix[i][j])
s.sort()
return s[k-1]
```