#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair const int inf = 1000000001; const ll INF = 1e16; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout< > > adj(N, vector< pair >()); vll hyou(8, vl(8, 0)); vl d(N, INF); vi r(8); int main() { int r, k, h, w, i, j, l, m; cin >> r >> k >> h >> w; vector< vector > c(h, vector(w)); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { cin >> c[i][j]; } } if (r == 0) { vector< vector > d(h*k, vector(w*k)); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { for (l = i*k; l < (i+1)*k; l++) { for (m = j*k; m < (j+1)*k; m++) { d[l][m] = c[i][j]; } } } } for (i = 0; i < h*k; i++) { for (j = 0; j < w*k; j++) { cout << d[i][j]; } cout << endl; } return 0; } else if (r == 90) { vector< vector > d(w*k, vector(h*k)); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { for (l = j*k; l < (j+1)*k; l++) { for (m = (h - i - 1)*k; m < (h - i)*k; m++) { d[l][m] = c[i][j]; } } } } for (i = 0; i < w*k; i++) { for (j = 0; j < h*k; j++) { cout << d[i][j]; } cout << endl; } return 0; } else if (r == 180) { vector< vector > d(h*k, vector(w*k)); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { for (l = (h - 1 - i)*k; l < (h - i)*k; l++) { for (m = (w - 1 - j)*k; m < (w - j)*k; m++) { d[l][m] = c[i][j]; } } } } for (i = 0; i < h*k; i++) { for (j = 0; j < w*k; j++) { cout << d[i][j]; } cout << endl; } return 0; } else if (r == 270) { vector< vector > d(w*k, vector(h*k)); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { for (l = (w - 1 - j)*k; l < (w - j)*k; l++) { for (m = i*k; m < (i + 1)*k; m++) { d[l][m] = c[i][j]; } } } } for (i = 0; i < w*k; i++) { for (j = 0; j < h*k; j++) { cout << d[i][j]; } cout << endl; } return 0; } }