There are candidates who applied for a prestigious scholarship program. Each candidate is evaluated based on different factors. The rating of the -th candidate on the -th factor is , where higher values indicate better performance.
The administration of the program has a secret importance ordering of the factors, which is a permutation of the numbers from to . For example, if the importance ordering is , it means that the third factor is the most important, followed by the first factor, then the second factor, and finally the fourth factor.
The importance ordering determines how the candidates are ranked. The candidates are first compared based on the most important factor, and ties are broken by the second most important factor, then the third most important, and so on. If candidates have identical ratings for all factors, the ties will be broken arbitrarily; those candidates can appear in any order. The administration has released the final ranking of the candidates, but not the importance ordering.
Given the ratings of all candidates on the factors and the final ranking, , can you find the secret importance ordering? If multiple possible orderings produce the same ranking, output the lexicographically minimal one. If no such ordering exists, output .
Constraints
()
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Input Specification
The first line of input contains two integers , , the number of candidates and the number of factors, respectively.
The second line of input contains integers, the array . The -th integer is the index of the candidate who ranked -th.
The next lines each contain integers, representing the ratings of the candidates. The -th line contains the ratings of the -th candidate, .
Output Specification
If a valid ordering of the factors exists, then output a single line containing integers, representing the ordering of the factors. If there are multiple possible orderings that produce the same ranking, output the lexicographically minimal one. Otherwise, output -1
.
Sample Input
11 3
11 4 6 1 3 10 5 7 8 2 9
4 4 2
2 1 2
2 4 2
3 4 4
4 3 4
1 4 4
2 3 3
4 1 4
1 1 2
1 4 1
3 4 4
Sample Output
2 3 1
Comments