#P7329. Find the k-th Smallest Disk Importance

    ID: 20528 Type: Default 1000ms 256MiB

Find the k-th Smallest Disk Importance

Find the k-th Smallest Disk Importance

Dream has divided Tommy's music disks into n categories. In the i-th category there are \(2^m-1\) disks. Each disk is assigned a unique positive integer representing its importance. In each category, the disks are sorted in increasing order of importance. Dream wants to know which disk is the k-th smallest in importance among all disks.

Since the total number of disks is very large, Dream will not provide the entire list of disk importance values. Instead, you can access the importance of the disk in the i-th category that is the j-th smallest.

You are given the sorted lists for each category in the input. Your task is to output the overall k-th smallest disk importance value.

inputFormat

The first line contains three integers n, m and k separated by spaces, where:

  • n is the number of categories,
  • each category contains exactly \(2^m-1\) disks,
  • k is the order of the overall disk importance to find.

This is followed by n lines. Each line contains \(2^m-1\) space-separated integers in increasing order representing the disk importance values in that category.

outputFormat

Output a single integer — the k-th smallest disk importance value among all disks.

sample

1 3 4
1 2 3 4 5 6 7
4

</p>