99. Bingo

I'm a slow walker, but I never walk backwards.

Task Description

Write a program to play bingo. A bingo board has $m$ rows and $m$ columns. Each entry has a different number from $1$ to $m \times m$. The numbers from $1$ to $m \times m$ will be randomly called. If a player has all the numbers in a row, a column, or a diagonal called he can declare bingo and win the game. Now given the bingo boards of $n$ players, determine who wins the bingo.


The first line of the input has $n$ and $m$. Each of the next $m$ lines has the $m$ numbers of the bingo board of the first player. The next line has the name of the second player, and the next $m$ lines have the numbers for the second player, and so on. The next line has $m \times m$ numbers that are called in sequence during the bingo game.


Print the indices of the winners of the game and by which number they won the game. If there are more than one winner, print the player indices one by one according to the order they appear in input.


  • $n$ positive is no more than $10$.
  • $m$ is positive and no more than $256$.
  • The length of a name is positive and no more than 64. The name consist of only letters.

Sample input

2 3
1 2 3
4 5 6
7 8 9
1 2 3
4 5 6
7 8 9
1 2 4 8 6 3 9 5 7

Sample output

3 Alice Blob