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 = 0; i < H; i++) { for(int j = 0; j < W; j++) { new_c[i][j] = c[H - i - 1][W - j - 1]; } } 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[H - j - 1][i]; } } disp(new_c, W, H, K); }else { 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][W - i - 1]; } } 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()); } } } }