#P1395B. Boboniu Plays Chess
Boboniu Plays Chess
No submission language available for this problem.
Description
Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.
You are a new applicant for his company. Boboniu will test you with the following chess question:
Consider a grid (rows are numbered from to , and columns are numbered from to ). You have a chess piece, and it stands at some cell which is not on the border (i.e. and ).
From the cell , you can move your chess piece to () or (). In other words, the chess piece moves as a rook. From the cell, you can move to any cell on the same row or column.
Your goal is to visit each cell exactly once. Can you find a solution?
Note that cells on the path between two adjacent cells in your route are not counted as visited, and it is not required to return to the starting point.
The only line of the input contains four integers , , and (, , ) — the number of rows, the number of columns, and the initial position of your chess piece, respectively.
You should print lines.
The -th line should contain two integers and (, ), denoting the -th cell that you visited. You should print exactly pairs , they should cover all possible pairs , such that , .
We can show that under these constraints there always exists a solution. If there are multiple answers, print any.
Input
The only line of the input contains four integers , , and (, , ) — the number of rows, the number of columns, and the initial position of your chess piece, respectively.
Output
You should print lines.
The -th line should contain two integers and (, ), denoting the -th cell that you visited. You should print exactly pairs , they should cover all possible pairs , such that , .
We can show that under these constraints there always exists a solution. If there are multiple answers, print any.
Samples
Note
Possible routes for two examples:
