Conveyor Belts

View as PDF

Submit solution


Points: 0.20 (partial)
Time limit: 2.0s
Memory limit: 256M
Input: stdin
Output: stdout

Author:
Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

You are an engineer who has made an emergency landing on a strange planet. You need to build a factory to return to space. For now, your task is to collect objects falling from the sky and gather them at a single location.

The objects are dropped in an area that is a grid of size ~n \times m~ (~4 \le n, m~). The rows of the grid are numbered from ~1~ to ~n~ from top to bottom, and the columns are numbered from ~1~ to ~m~ from left to right. The cell at the intersection of row ~r~ (~1 \le r \le n~) and column ~c~ (~1 \le c \le m~) is denoted as ~(r, c)~.

You need to transport the objects to a given cell ~(i, j)~. Except for cell ~(i, j)~, you must install conveyor belts on all other cells. For each conveyor belt, you need to choose one of four directions: up, down, left, or right. A conveyor belt in a cell can transport an object on it to the adjacent cell in the installed direction. You must install the conveyor belts so that the following conditions are satisfied:

  • If an object falls on any cell in the grid, the conveyor belt system can deliver the object to cell ~(i, j)~;

  • For each direction (up, down, left, or right), there must be at least one conveyor belt installed in that direction.

Find a way to install the conveyor belts that satisfies the above conditions. It can be shown that, with the given constraints, there always exists a valid installation. If there are multiple possible installations, find any one of them.

Input

Each test consists of multiple test cases. The first line of the input contains a positive integer ~t~ (~1 \le t \le 10\,000~)—the number of test cases. The description of each test case is as follows.

The first and only line of each test case contains four positive integers ~n~, ~m~, ~i~, ~j~ (~4 \le n, m \le 10^6~, ~1 \le i \le n~, ~1 \le j \le m~)—the size of the area and the coordinates of the collection cell.

It is guaranteed that the sum of ~n \cdot m~ over all test cases does not exceed ~4 \cdot 10^6~.

Output

For each test case, print ~n~ lines, each containing ~m~ characters. The ~c~-th character on the ~r~-th line represents the direction of the conveyor belt installed at cell ~(r, c)~:

  • ^ – indicates a conveyor belt facing up;

  • v – indicates a conveyor belt facing down;

  • < – indicates a conveyor belt facing left;

  • > – indicates a conveyor belt facing right;

  • . – indicates the target cell. This character should only be used at cell ~(i, j)~.

If there are multiple valid ways to install the conveyor belts, output any one of them.

Scoring

The total score for this problem is ~1250~.

Sample Input 1

2
4 5 3 2
4 4 4 4

Sample Output 1

>>>v<
vv<<^
>.^v<
^^<<^
>>vv
^^v<
>^>v
>>>.

Notes

In the first test case, when an object is dropped at cell ~(1, 1)~, it will be transported to cell ~(i, j) = (3, 2)~ by the conveyor belts as follows: $$(1, 1) \xrightarrow{>} (1, 2) \xrightarrow{>} (1, 3) \xrightarrow{>} (1, 4) \xrightarrow{\vee} (2, 4) \xrightarrow{<} (2, 3) \xrightarrow{<} (2, 2) \xrightarrow{\vee} (3, 2)$$


Comments

Please read the guidelines before commenting.


There are no comments at the moment.