r, k = map(int, input().split()) h, w = map(int, input().split()) assert r == 0 or r == 90 or r == 180 or r == 270, 'invalid input: r' assert 1 <= k <= 10, 'invalid input: k' assert 1 <= h <= 10, 'invalid input: h' assert 1 <= w <= 10, 'invalid input: w' def rot(vs): h_ = len(vs); w_ = len(vs[0]) ret = [['X' for j in range(h_)] for i in range(w_)] for hh in range(h_): for ww in range(w_): ret[ww][hh] = vs[hh][ww] return ret def scale(vs): h_ = len(vs); w_ = len(vs[0]) ret = [['X' for i in range(w_*k)] for j in range(h_*k)] for hh in range(len(ret)): for ww in range(len(ret[0])): ret[hh][ww] = vs[hh // k][ww // k] return ret vs = [list(input()) for i in range(h)] for i in range(len(vs)): for j in range(len(vs[i])): assert vs[i][j] == '.' or vs[i][j] == '#', "invalid input: c" for i in range(r // 90): vs = rot(vs) vs = scale(vs) for i in range(len(vs)): print(''.join(vs[i]))