Problem D: Surveying 

Problem

After the radar station in Skrund (Latvia) has been abolished, Russian Ministry of Peace decided to build a new radar station in other neighbouring country.

Before building and projecting it is necessary to provide a surveying of the site where the radar station will be build. To do this, first of all one introduces a coordinate grid in the rectangular region K×M, where 0<K,M<=100. Thus every node of the grid (the intersection of a grid lines) has coordinates (i,j), 1<=i<=K, 1<=j<=M. The result of surveying is geodetical site plan, i.e. the table, which contains the relative heights of all the grid nodes measured with respect to distinguished node, called base. All the preliminary works including surveying are carrying out in the top-secret mode. In particular, one is not allowed to clear the site. This restricts visibility very much. That is why the surveying is carrying out in stages. One choose the point of surveying and measure the heights with respect to this point for all the visible nodes. Then one passes to the second point of surveying, and so on. Every time the heights with respect to the current point of surveying are measured. After the measuring from all the points of surveying has been completed, one recalculates the heights with respect to the base and write it down to the geodetical site plan.

You are expected to write a program, which will read the measurement results and form a geodetical site plan.

Input

The input will consist of N input blocks separated by a blank line. The amount N of input blocks will be given in the very first line and followed by a blank line.

The structure of the each input block will be the following. In the first line there will be two integers K and M defining the size of the site. The second line will contain two integers also separated by a space, i and j - the coordinates of the base. This two lines will be followed by measurements from different points of surveying. The measurements from each surveying point will be placed in one line. It will be a series of triples of integers separated by a space. Each triple will have the following form: i j h , where i j are the coordinates of the node, h - its weight in millimeters with respect to the current surveying point. There will be also a space between the triples. This series is terminated by <EOLN>. The last line of the input block will be followed by blank line.

The last line of the last input block will be followed immediately by <EOF>.

Note that used geodetical equipment does not allow to measure the heights of absolute value greater than 1 meter. (If the point locates below the point of surveying, we think that its relative height is negative.)

Output

For every input block there should be appropriate output block. Please, separate all the output blocks with a blank line and do not place a blank line after the last output block.

Each output block should contain the geodetical site plan, if it can be built according to the given measurements, or the proper error message.

The geodetical site plan should be written in the following way:

h11 h12 h13 ... h1M
h21 h22 h23 ... h2M
.................
hK1 hK2 hK3 ... hKM
where hij is the relative height of the node (i,j) with respect to the base, in millimeters.

Errors

The program should process two errors.

If there is not enough measurements to build a geodetical site plan, the output should consist of one string with an inscription "the lack of measurements".

If there are conflicting measurements, i.e. the height of some node can be determined not uniquely, the output should consist of one string "conflicting measurements".

If there are both conflicting measurements and the lack of measurement, you should output only "conflicting measurements".

Sample Input

3

2 2
1 2
1 1 10 1 2 10
1 2 20 2 2 30 2 1 30

2 2
1 1
1 1 10 1 2 10

2 2
1 2
1 1 10 1 2 10
1 1 20 1 2 30

Sample Output

0 0
10 10

the lack of measurements

conflicting measurements


Alexander Denisjuk, 2000