#include #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() #define dunk(a) cout << (a) << endl using namespace std; typedef long long ll; void print(vector C) { int H = C.size(); rep(i, H) dunk(C[i]); return; } vector rotate(vector C, int R) { if (R == 0) return C; int H = C.size(); int W = C[0].length(); if (R == 90) { vector res(W); rep(i, W) { res[i] = ""; rep(j, H) res[i] += C[H - 1 - j][i]; } return res; } if (R == 180) { vector res(H); rep(i, H) { res[i] = ""; rep(j, W) res[i] += C[H - 1 - i][W - 1 - j]; } return res; } if (R == 270) { vector res(W); rep(i, W) { res[i] = ""; rep(j, H) res[i] += C[j][W - 1 - i]; } return res; } return C; } vector scale(vector C, int k) { int H = C.size(); int W = C[0].size(); vector res(H * k); rep(i, H * k) { rep(j, W * k) { res[i] += C[i / k][j / k]; } } return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); int R, k, H, W; cin >> R >> k >> H >> W; vector C(H); rep(i, H) cin >> C[i]; C = rotate(C, R); C = scale(C, k); print(C); return 0; }