After finishing his daily leaf raking, Mr. Wincenty decided to relax with his favorite pastime: assembling a jigsaw puzzle. He found an old set in his desk drawer and started putting it together.
After a while he already knew which piece fits with which, and he also knew the first two pieces of the first row of the puzzle. He of course also knew the size of the finished picture (its number of rows and columns). Is this knowledge enough to reconstruct the entire puzzle uniquely?
The first line contains two natural numbers N and M (3≤N≤M, N⋅M≤1000). N is the number of rows of the puzzle and M is the number of columns.
The next N⋅M lines describe the pieces in order, from piece 1 to piece N⋅M. Each line contains exactly four non-negative integers: the numbers of the pieces that fit together with this piece. Because a piece may be rotated, these four values are given in no particular side order. If the piece lies on the border of the picture and a side has no neighbor, the number 0 is given in place of that neighbor.
The last line contains two natural numbers A and B: the numbers of the first and second pieces of the first row of the puzzle, respectively.
If the given data does not determine the puzzle's solution uniquely, print NIE. Otherwise print the assembled puzzle on N lines, where each line contains the M piece numbers of that row in order, separated by single spaces.