Jigsaw Puzzle

No attempts yetTime limit1sMemory limit128 MB

Problem

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?

Input

The first line contains two natural numbers NN and MM (3NM3 \le N \le M, NM1000N \cdot M \le 1000). NN is the number of rows of the puzzle and MM is the number of columns.

The next NMN \cdot M lines describe the pieces in order, from piece 11 to piece NMN \cdot 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 00 is given in place of that neighbor.

The last line contains two natural numbers AA and BB: the numbers of the first and second pieces of the first row of the puzzle, respectively.

Output

If the given data does not determine the puzzle's solution uniquely, print NIE. Otherwise print the assembled puzzle on NN lines, where each line contains the MM piece numbers of that row in order, separated by single spaces.