import java.io.*;
import java.util.*;
public class Main{
static StringBuilder sb = new StringBuilder();
static int[][] rotation;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
int R = Integer.parseInt(st.nextToken());
rotation = new int[N][M];
int[][] temp = new int[N][M];
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine(), " ");
for (int j = 0; j < M; j++) {
rotation[i][j] = Integer.parseInt(st.nextToken());
}
}
for (int i = 0; i < R; i++) {
rotate(N, M, Math.min(N / 2, M / 2));
}
System.out.println(printArray(rotation));
}
static void rotate(int N, int M, int r) {
int[][] temp = new int[N][M];
for (int ro = 0; ro < r; ro++) {
for (int i = ro + 1; i < M - ro; i++) {
temp[ro][i - 1] = rotation[ro][i];
}
for (int i = ro; i < N - ro - 1; i++) {
temp[i + 1][ro] = rotation[i][ro];
}
for (int i = ro; i < M - ro - 1; i++) {
temp[N - ro - 1][i + 1] = rotation[N - ro - 1][i];
}
for (int i = N - ro - 1; i > ro; i--) {
temp[i - 1][M - ro - 1] = rotation[i][M - ro - 1];
}
}
rotation = new int[N][M];
rotation = temp;
}
static String printArray(int[][] a) {
sb.setLength(0);
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
sb.append(a[i][j]).append(" ");
}
sb.append("\n");
}
sb.setLength(sb.length() - 1);
return sb.toString();
}
}