public int findKthNumber(int m, int n, int k) {
PriorityQueue<CellInfo> minHeap = new PriorityQueue<>();
for (int i = 1; i <= n; i++) {
minHeap.add(new CellInfo(1, i, i));
for (int i = 2; i <= k; i++) {
CellInfo curCell = minHeap.remove();
// System.out.println("current value: " + curCell.val);
int curRow = curCell.row;
int curCol = curCell.col;
minHeap.add(new CellInfo(curRow + 1, curCol, (curRow + 1) * curCol));
return minHeap.peek().val;
class CellInfo implements Comparable<CellInfo> {
public CellInfo(int row, int col, int val) {
public int compareTo(CellInfo that) {
return this.val - that.val;