R,K = map(int,input().split()) H,W = map(int,input().split()) maps = [list(input()) for j in range(H)] cpmap = [] def editmap(): global cpmap if R==90 or R==270: h,w = W,H else: h,w = H,W cpmap = [["" for i in range(w)]for j in range(h)] if R==0: for hi in range(h): for wi in range(w): cpmap[hi][wi]=maps[hi][wi]*K elif R==90: for hi in range(h): for wi in range(w): cpmap[hi][wi]=maps[H-wi-1][hi]*K elif R==180: for hi in range(h): for wi in range(w): cpmap[hi][wi]=maps[H-hi-1][W-wi-1]*K else: for hi in range(h): for wi in range(w): cpmap[hi][wi]=maps[wi][h-hi-1]*K def prtmap(mp): for i in range(len(mp)): for j in range(K): print("".join(mp[i])) editmap() prtmap(cpmap)