Several C-shaped blocks are placed on an n by n square board. A C-shaped block is made by removing one smaller rectangle from a rectangle. The removed rectangle touches exactly one side of the original rectangle.
One T-shaped block is also given. It consists of a bar and a stem attached to that bar. The positive integers u, v, w, x, y describe the unrotated T-shaped block as follows.
u and thickness v.y cells along the bar and x cells perpendicular to the bar.w cells away from the left edge of the bar.The T-shaped block may be rotated and inserted into the notch of a C-shaped block. After insertion, the target C-shaped block and the T-shaped block must form one rectangle. Find every C-shaped block on the board for which this is possible.
Observe the following rules.
The first line contains n, the side length of the board. n is at most 50.
The second line contains the positive integers u, v, w, x, y, which describe the T-shaped block.
The next n lines describe the board. A cell containing part of a C-shaped block is written as 1, and an empty cell is written as 0. Every block on the board is C-shaped, and no two different C-shaped blocks share an edge.
On the first line, print the number of C-shaped blocks that can form a rectangle with the T-shaped block.
Starting on the second line, print the upper-left corner position of each such C-shaped block, one per line. A position is written as the row counted from the top and the column counted from the left, separated by one space. Rows and columns are counted from 1.
If there are multiple positions, they may be printed in any order. If there is no such C-shaped block, print only 0.