import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static int RANGE = 100; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int R = sc.nextInt(); final int K = sc.nextInt(); final int H = sc.nextInt(); final int W = sc.nextInt(); char[][] board = new char[H][]; for(int i = 0; i < H; i++){ board[i] = sc.next().toCharArray(); } final int rot_H = (R == 90 || R == 270) ? W : H; final int rot_W = (R == 90 || R == 270) ? H : W; char[][] rot_board = new char[rot_H][rot_W]; if(R == 90){ for(int y = 0; y < H; y++){ for(int x = 0; x < W; x++){ rot_board[x][(H - 1) - y] = board[y][x]; } } }else if(R == 270){ for(int y = 0; y < H; y++){ for(int x = 0; x < W; x++){ rot_board[(W - 1) - x][y] = board[y][x]; } } }else if(R == 180){ for(int y = 0; y < H; y++){ for(int x = 0; x < W; x++){ rot_board[(H - 1) - y][(W - 1) - x] = board[y][x]; } } }else{ for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ rot_board[i][j] = board[i][j]; } } } for(int i = 0; i < rot_H * K; i++){ for(int j = 0; j < rot_W * K; j++){ System.out.print(rot_board[i / K][j / K]); } System.out.println(); } } }