您的位置:首页 > 其它

ACdream群OJ--1035

2014-05-01 01:06 274 查看


An Unfair Game

Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others)

SubmitStatistic Next
Problem


Problem Description

There are n people and n target, everyone should get one target, no two people get the same target, the last one who get the target should be punished, there is only one person will be punished, so if more than one person are the last, no one will be punished.
As the judge, you know exactly how much time that people i getting target j will spend, but there are no people know how much time he needs. You need to arrange for a target to everyone, and you want the i-th people to be punished (Now you know why it is an
unfair game?).


Input

The input contains several test, and ends with EOF. For each test, the first line has an integer n,which is the number of people and target,next there is an integer matrix which size is n*n, the i-th row and the
j-th colume of matrix means the time that i-th person needs to get target j. Next line is a number m, the number of the person who you want to be punished.
1<=m<n<=100


Output

Each test print one line, the number of the target that m-th person gets, if there are more than one answer, print all of them. If there is no answer, only print -1.


Sample Input

3
1 2 3
2 3 4
3 4 5
3
3
3 3 3
2 2 2
1 1 1
3



Sample Output

2 3
-1



Source

UUZ


Manager

nanae

SubmitStatistic
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: