This page is still under construction.

Parts of this page are still being built. What you see may change.

Robot Vacuum 2

Time limit12sMemory limit1024 MB

Summary
Given a grid warehouse with boxes and a start cell, output a command string of length N that maximizes the number of distinct cells the vacuum visits.
Level

Hard9 of 10

Topics
Greedy, Simulation, Graph, Brute force
Solved
No attempts yet

Problem

The problem Robot Vacuum was about counting how many cells a robot vacuum visits in a grid. In this problem, you are given the grid and the length of the command sequence, and must instead find a command sequence that makes the vacuum visit as many different cells as possible.

Your score depends on how well your solution performs compared to the judges' solution. This means that getting 100100 points may be difficult, but collecting partial points does not have to be very hard.

Input

The input consists of 1010 test cases.

  • The first line contains an integer TT (0≤T≤100 \leq T \leq 10), the number of the test case (00 is the example case below).
  • The second line contains three integers: RR (3≤R≤20003 \le R \le 2000) and CC (3≤C≤20003 \le C \le 2000), the number of rows and columns in the grid-shaped warehouse, and NN (1≤N≤20001 \le N \le 2000), the length of the command sequence.
  • The following RR lines describe the grid-shaped warehouse. The ii-th of these lines contains CC characters describing the ii-th row. Each character is either a period "." if a cell is empty, a hash "#" if a cell contains a box, or "O" if the cell is the robot's starting position. Exactly one cell is guaranteed to contain "O". In addition, every cell on the edge of the grid is guaranteed to be "#".

Output

Print one line containing a string of length NN made up of the characters "^", ">", "v", "<". This is the command sequence the vacuum will follow.

Examples1

  1. Example 1

    Input
    0
    8 10 14
    ##########
    #.#......#
    #....#...#
    ##......O#
    #........#
    #..#.....#
    #....#...#
    ##########
    
    Expected output
    <v>^<v>v<^^><>