# -*- coding: utf-8 -*- """ No.565 回転拡大 https://yukicoder.me/problems/no/565 """ import sys from sys import stdin input = stdin.readline def rotate_pict(R, pict): H = len(pict) W = len(pict[0]) if R == 90 or R == 270: H, W = W, H rpict = [['.']* W for _ in range(H)] for y in range(H): for x in range(W): if R == 0: rpict[y][x] = pict[y][x] elif R == 180: rpict[y][x] = pict[H-y-1][W-x-1] elif R == 90: rpict[y][x] = pict[W-x-1][y] elif R == 270: rpict[y][x] = pict[x][H-y-1] return rpict def main(args): R, K = map(int, input().split()) H, W = map(int, input().split()) pict = [] for _ in range(H): pict.append(list(input().strip())) rpict = rotate_pict(R, pict) for row in rpict: for i in range(K): for r in row: print(r * K, end='') print() if __name__ == '__main__': main(sys.argv[1:])