import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int R = scan.nextInt(); int K = scan.nextInt(); int H = scan.nextInt(); int W = scan.nextInt(); int[][]c = new int[H][W]; for(int i = 0; i < H; i++) { String s = scan.next(); for(int j = 0; j < W; j++) { if(s.charAt(j) == '#') { c[i][j] = 1; } } } scan.close(); if(R == 0) { disp(c, H, W, K); }else if(R == 180) { int[][] new_c = new int[H][W]; for(int i = H - 1; i >= 0; i--) { for(int j = W - 1; j >= 0; j--) { new_c[i][j] = c[i][j]; } } disp(new_c, H, W, K); }else if(R == 90) { int[][] new_c = new int[W][H]; for(int i = 0; i < W; i++) { for(int j = 0; j < H; j++) { new_c[i][j] = c[j][i]; } } disp(new_c, W, H, K); }else { int[][] new_c = new int[W][H]; for(int i = W - 1; i >= 0; i--) { for(int j = H - 1; j >= 0; j--) { new_c[i][j] = c[j][i]; } } disp(new_c, W, H, K); } } static void disp(int[][] cell, int r, int c, int t) { for(int i = 0; i < r; i++) { StringBuilder sb = new StringBuilder(); for(int j = 0; j < c; j++) { char ch = '.'; if(cell[i][j] == 1) { ch = '#'; } for(int k = 0; k < t; k++) { sb.append(ch); } } for(int k = 0; k < t; k++) { System.out.println(sb.toString()); } } } }