eolymp
bolt
Try our new interface for solving problems
Məsələlər

Rotate Text Blocks

Rotate Text Blocks

Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB

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

Giriş verilənləri

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

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

  • 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 upper/lower case alphabets ("A"-"Z", "a"-"z") or periods ".".

Çıxış verilənləri

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

Nümunə

Giriş verilənləri #1
2
2 3
Hel
lo.
1 1
X
Çıxış verilənləri #1
l.
eo
Hl

X
Mənbə University of Toronto 2010 ACM Tryout: Saturday, October 2, 2010