#include <iostream>

#define fi first
#define se second
#define pb(x) push_back(x)
#define sqr(x) ((x)*(x))
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define cs(x) printf("Case %d: ", x)

using namespace std;
template <class T> inline void umax(T &x,T y) {if (y > x) x = y;}
template <class T> inline void umin(T &x,T y) {if (y < x) x = y;}
typedef long long ll;
typedef pair <int, int> pii;

const int N = 2e2 + 5, B = 0x7fffffff;
int a[N][N], ans[N][N];
int n, m, x;

int main(){
  cin >> n >> m >> x;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  int cl = 1, cr = 1;
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      for (int pq = cr; pq <= cr + x - 1; pq++)
      for (int ps = cl; ps <= cl + x - 1; ps++)
        ans[pq][ps] = a[i][j];
      cl += x;
    }
    cr += x;
    cl = 1;
  }
  for (int i = 1; i <= n * x; i++){
    for (int j = 1; j <= m * x; j++)
      cout << ans[i][j] << " ";
    cout << "\n";
  }
  
  return !1;
}