The Great Wall
King Louis has two sons who despise each other. Fearing that his kingdom might fall into ruinous wars after his passing, he decides to split the country into two separate regions, each governed by one son. He places them on thrones in cities (A) and (B) and aims to construct the fewest possible wall segments to ensure there is no path connecting city (A) to city (B).
The kingdom can be visualized as a rectangle of size (m n). Some cells within this rectangle contain mountains, making them impassable, while others can be traversed freely. Additionally, certain cells are suitable for wall construction, whereas others are not.
Movement across the kingdom is restricted to adjacent cells by side, provided neither cell contains a mountain or a wall segment.
Input
The first line of the input provides the dimensions (m) and (n) ((1 m, n 50)). The second line gives the numbers (k) and (l), where (0 k, l, k + l m n - 2). Here, (k) represents the number of cells with mountains, and (l) indicates the number of cells where walls can be built. Walls cannot be constructed on mountains. The next (k) lines list the coordinates of mountain cells ((x_i, y_i)), followed by (l) lines listing the coordinates of cells suitable for wall construction ((x_j, y_j)). The final two lines provide the coordinates of cities (A) ((x_A, y_A)) and (B) ((x_B, y_B)). None of the coordinates in these (k+l+2) lines overlap. It is guaranteed that (1 x_i, x_j, x_A, x_B m) and (1 y_i, y_j, y_A, y_B n).
Output
The output should begin with the minimum number of wall segments (F) required. The following (F) lines should detail one possible configuration for the wall construction.
If it is impossible to achieve the desired separation, the output should simply be the number (-1).