#Lutece0543. PaPaPa
PaPaPa
Migrated from Lutece 543 PaPaPa
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Mzry1992 invented a new programming language, and named it PaPaPa
. PaPaPa
uses a pointer and the pointer moves in a code rectangle. At the beginning, the pointer located in the left-upper corner and the working direction is right. When meeting a character, it will execute a particular command. See the form below to learn about this. Given the code of the program, can you tell us the result of the program?
Token | Description |
---|---|
`^` | Go up from current position |
`>` | Go **right** from current position |
`v` | Go up from current position |
`<` | Go **left** from current position |
Character `A`-`Z` | Output Character `A`-`Z` |
`@` | Stop the program |
Notice that if the pointer goes out of the code rectangle the program will stop too.
And if the program can’t be stop and repeatedly output a series of character, use the brackets []
to show that.
Input
There is only one integer () in the first line, indicates the number of test cases.
Then parts follows, each begin with a line with integers , (). And there would be the code within a rectangle of a size of .
Output
For each part, output the result of the program.
Samples
4
1 14
HELLOWORLD@AAA
1 14
HELLOWORLD><AA
2 20
>YUKKURISHITEITTENEv
^<<<<<<<<<<<<<<<<<<<
3 7
ABCDEFv
HIJKLMN
OP^RST<
HELLOWORLD
HELLOWORLD[]
[YUKKURISHITEITTENE]
ABCDEFNTSRJC
Resources
mzry1992