import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int r = sc.nextInt(); int k = sc.nextInt(); int h = sc.nextInt(); int w = sc.nextInt(); char[][] org = new char[h][]; for (int i = 0; i < h; i++) { org[i] = sc.next().toCharArray(); } char[][] next; if (r == 0) { next = org; } else { if (r == 180) { next = new char[h][w]; } else { next = new char[w][h]; } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (r == 90) { next[j][h - i - 1] = org[i][j]; } else if (r == 180) { next[h - i - 1][w - j -1] = org[i][j]; } else { next[w - j - 1][i] = org[i][j]; } } } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < next.length; i++) { StringBuilder tmp = new StringBuilder(); for (int j = 0; j < next[i].length; j++) { for (int a = 0; a < k; a++) { tmp.append(next[i][j]); } } tmp.append("\n"); for (int a = 0; a < k; a++) { sb.append(tmp); } } System.out.print(sb); } }