import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class 실험실 {
static int N,M,R;
static int[][] arr;
static int[] directionX = {0,1,0,-1};
static int[] directionY = {1,0,-1,0};
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
StringBuilder sb = new StringBuilder("");
N = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());
R = Integer.parseInt(st.nextToken());
arr = new int[N][M];
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
for (int j = 0; j < M; j++) {
arr[i][j] = Integer.parseInt(st.nextToken());
}
}
int s = Math.min(N, M) / 2;
for (int i = 0; i < R; i++) {
rotate(s);
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
sb.append(arr[i][j]).append(" ");
}
sb.append("\n");
}
System.out.print(sb);
}
static void rotate(int s) {
for(int i = 0 ; i < s; i++) {
int direction= 0 ;
int sx = i;
int sy = i;
int temp = arr[sx][sy];
while (direction < 4) {
int nextX = sx + directionX[direction];
int nextY = sy + directionY[direction];
if(nextX < i && nextY < i && nextX >= N-i && nextY >= M-i ) {
arr[sx][sy] = arr[nextX][nextY];
sx = nextX;
sy = nextY;
}else {
direction ++;
}
}
arr[i+1][i] = temp;
}
}
}