Little A's matrix
题号:NC223760
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

    little A and little Huan are both smart ACMer. little Huan likes to study matrix problems. One day, little A gave little Huan an interesting matrix problem. little A provides little Huan with a matrix of of n lines m columns and four integers  . Using the matrix and the integers , determine the value of the element in the  row and   column of the matrix is  . Now Little A asks Huan what is the K'th smallest element of this matrix. For example, 1,2,3,4. The 2'th smallest value is 2.


输入描述:

The first line contains three integers ,represents the size of the matrix and the K'th largest.

The second line contains three integers

输出描述:

Print one integer----the K'th smallest element of this matrix
示例1

输入

复制
3 3 4
1 1 1

输出

复制
7
示例2

输入

复制
3 3 2
1 1 0

输出

复制
2

说明

Sample 1 consists of the following matrix:

hus the fourth smallest of the matrix is 7