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[][] fig = new char[h][w]; for(int i = 0; i < h; i++) { String s = sc.next(); for(int j = 0; j < w; j++) { fig[i][j] = s.charAt(j); } } char[][] rot; int row = 0; int col = 0; if(r == 0) { rot = fig; row = k * h; col = k * w; } else if(r == 90) { rot = new char[w][h]; row = k * w; col = k * h; for(int i = 0; i < w; i++) { for(int j = 0; j < h; j++) { rot[i][j] = fig[h - 1 - j][i]; } } } else if(r == 180) { rot = new char[h][w]; row = k * h; col = k * w; for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { rot[i][j] = fig[h - 1 - i][w - 1 - j]; } } } else { rot = new char[w][h]; row = k * w; col = k * h; for(int i = 0; i < w; i++) { for(int j = 0; j < h; j++) { rot[i][j] = fig[j][w - 1 - i]; } } } for(int i = 0; i < row; i++) { String s = ""; for(int j = 0; j < col; j++) { s += String.valueOf(rot[i / 3][j / 3]); } System.out.println(s); } } }