#include <bits/stdc++.h>

//#define fin cin
//#define fout cout

#define F first
#define S second

using namespace std;

typedef long long ll;

int n , m , x , i , j , N , M , p1 , p2;
int a[110][110];

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif // ONLINE_JUDGE

    scanf("%d %d %d", &n, &m, &x);
    for (i = 1; i <= n; ++i)
        for (j = 1; j <= m; ++j)
            scanf("%d", &a[i][j]);

    N = n * x; M = m * x;

    for (i = 1; i <= N; ++i, printf("\n"))
        for (j = 1; j <= M; ++j)
    {
        p1 = i / x + 1; if (i % x == 0) p1--;
        p2 = j / x + 1; if (j % x == 0) p2--;

        printf("%d ", a[p1][p2]);
    }

    return 0;
}