Rotate Text Blocks#3832

Rotate Text Blocks

1 second
64 megabytes
Easy

Given a rectangular block of text, your task is to rotate it counter-clockwise by , and print the result.

Input

The first input line contains the number of test cases , 1 \le N \le 50.

Each test case begins with a line containing integers and , separated by space. lines follow. Each line , 1 \le i \le h, contains a length- string s_i. The text block s_1, s_2, ..., s_h, when stacked vertically, specifies the input text block.

  • is the height of the text block, and satisfies 1 \le h \le 50.

  • is the width of the text block, and satisfies 1 \le w \le 50.

  • For each , 1 \le i \le h, s_i is a length- string of upper/lower case alphabets (""-"", ""-"") or periods "".

Output

For each test case, rotate the input text block counter-clockwise by , and print it as lines of length- strings. Print an empty line between test cases, but not after the last test case.

Examples

Example 1

Loading
Loading