{"problem":{"name":"King's Tour","description":{"content":"We have an $H \\times W$ chessboard with $H$ rows and $W$ columns, and a king.   Let $(i, j)$ denote the square at the $i$\\-th row from the top $(1 \\leq i \\leq H)$ and $j$\\-th column from the left $(1 ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc232_h"},"statements":[{"statement_type":"Markdown","content":"We have an $H \\times W$ chessboard with $H$ rows and $W$ columns, and a king.  \nLet $(i, j)$ denote the square at the $i$\\-th row from the top $(1 \\leq i \\leq H)$ and $j$\\-th column from the left $(1 \\leq j \\leq W)$.  \nThe king can move one square in any direction. Formally, the king on $(i,j)$ can move to $(k,l)$ if and only if $\\max(|i-k|,|j-l|) = 1$.\nA _tour_ is the process of moving the king on the $H \\times W$ chessboard as follows.\n\n*   Start by putting the king on $(1, 1)$. Then, move the king to put it on each square exactly once.\n\nFor example, when $H = 2, W = 3$, going $(1,1) \\to (1,2) \\to (1, 3) \\to (2, 3) \\to (2, 2) \\to (2, 1)$ is a valid tour.\nYou are given a square $(a, b)$ other than $(1, 1)$. Construct a tour ending on $(a,b)$ and print it. It can be proved that a solution always exists under the Constraints of this problem.\n\n## Constraints\n\n*   $2 \\leq H \\leq 100$\n*   $2 \\leq W \\leq 100$\n*   $1 \\leq a \\leq H$\n*   $1 \\leq b \\leq W$\n*   $(a, b) \\neq (1, 1)$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$H$ $W$ $a$ $b$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc232_h","tags":[],"sample_group":[["3 2 3 2","1 1\n1 2\n2 1\n2 2\n3 1\n3 2\n\nThe king goes $(1, 1) \\to (1, 2) \\to (2, 1) \\to (2, 2)\\to (3, 1) \\to (3, 2)$, which is indeed a tour ending on $(3, 2)$.  \nThere are some other valid tours, three of which are listed below.\n\n*   $(1, 1) \\to (1, 2) \\to (2, 2) \\to (2, 1) \\to (3, 1) \\to (3, 2)$\n*   $(1, 1) \\to (2, 1) \\to (1, 2) \\to (2, 2) \\to (3, 1) \\to (3, 2)$\n*   $(1, 1) \\to (2, 2) \\to (1, 2) \\to (2, 1) \\to (3, 1) \\to (3, 2)$"]],"created_at":"2026-03-03 11:01:14"}}