| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 12 | 3 | 3 | 25.000% |
Vova has a magnet which is his favorite toy. Vova likes to play with it on a big field which can be represented as rectangle of $n$ cells height and $m$ cells width.
One day he came to the field with his magnet and lost it in one of the cells. Vova was frustrated, but found a solution --- he puts a compass in each cell of the field. Compass arrow may be oriented in one of the following 8 directions. Each direction has its own number:
Arrows take direction close to the direction to the magnet: if the magnet is strictly along the diagonal to the compass, arrow of this compass points diagonally, otherwise --- it points in the closest of the vertical and the horizontal direction to the magnet. Arrow of the compass in the cell with the magnet may be directed anywhere.
Illustration for the sample test, arrows of all compasses point to the magnet.
Vova was ready to start searching, but suddenly recalled that there is an anomaly at the field, that inverts compasses along one horizontal and one vertical line. Arrows of the comapasses in the anomaly zone point in the opposite direction to the correct one.
Illustration for the sample, readings of some of the compasses are inverted.
Now Vova doesn't know how to find his magnet and asks you for help.
The first line of the input contains two integers $n$ and $m$ --- size of the field (2ドル \le n, m \le 1500, nm \ge 6$).
The following $n$ lines contain information about compasses on the field.
The $i$-th line contains $m$ integers $a_{i,j}$ (1ドル \le a_{i,j} \le 8$), the $j$-th number on the $i$-th line describes the direction of the compass arrow in the $j$-th cell on the $i$-th line.
The first line of output should contain two integers $x$ and $y$ --- the row and the column of the cell where the magnet is.
The second line must contain two integers $a$ and $b$ --- which the horizontal and which vertical line are affected by the anomaly.
3 4 5 6 3 7 3 7 3 7 5 4 3 3
2 1 3 3
The magnet in sample input is in the cell $(2, 1),ドル the anomaly inverts horizontal number 3ドル$ and vertical number 3ドル$.