// Arup Guha
// 1/8/2016
// Solution to 2016 Dec USACO Bronze Problem: Cow Signal

import java.util.*;
import java.io.*;

public class cowsignal {

	public static void main(String[] args) throws Exception {

		// Open file.
		Scanner stdin = new Scanner(new File("cowsignal.in"));
		int r = stdin.nextInt();
		int c = stdin.nextInt();
		int k = stdin.nextInt();

		// Read in grid.
		char[][] grid = new char[r][];
		for (int i=0; i<r; i++)
			grid[i] = stdin.next().toCharArray();

		char[][] big = new char[r*k][c*k];

		// Loop through top left corner of each "pixel"
		for (int i=0; i<r*k; i+=k) {
			for (int j=0; j<c*k; j+=k) {

				// Copy the single character from original into each of these.
				for (int a=0; a<k; a++)
					for (int b=0; b<k; b++)
						big[i+a][j+b] = grid[i/k][j/k];
			}
		}

		// Ta da!
		PrintWriter out = new PrintWriter(new FileWriter("cowsignal.out"));
		for (int i=0; i<r*k; i++)
			out.println(new String(big[i]));
		out.close();
		stdin.close();
	}

}