eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Prettify Text Blocks

Prettify Text Blocks

Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB

You are given a rectangular text block, consisting of periods "." and asterisks "*". Two horizontally or vertically adjacent asterisks are connected. You task is to convert each asterisk to a different character, depending on how it connects to other asterisks. An asterisk is converted to:

  • "o" (the lower case letter o) if it is not connected,

  • "-" if it is only connected horizontally (left/right/left and right),

  • "|" if it is only connected vertically (up/down/up and down),

  • "+" otherwise.

Вхідні дані

The first input line contains the number of test cases N, 1N50.

Each test case begins with a line containing integers h andw, separated by space. h lines follow. Each line i, 1ih, consists of a string s. The input text block is represented by vertically stacking s_1, s_2, ..., s_h.

  • h is the height of the text block, and satisfies 1h50.

  • w is the width of the text block, and satisfies 1w50.

  • For each i, 1ih, s_i is a length-w string of periods "." or asterisks "*".

Вихідні дані

For each test case, print h lines of length-w strings, represents the converted text block. Print a blank line between test cases, but not after the last test case.

Приклад

Вхідні дані #1
2
4 5
*****
*...*
*...*
*****
7 7
*******
.*.*.*.
.****..
*....**
...*...
**.*.**
**.*..*
Вихідні дані #1
+---+
|...|
|...|
+---+

-+-+-+-
.|.|.|.
.+-+-..
o....--
...|...
++.|.-+
++.|..|
Джерело University of Toronto 2010 ACM Tryout: Saturday, October 2, 2010