#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ void print(vector C) { int H = C.size(); rep(y, 0, H) cout << C[y] << endl; } //--------------------------------------------------------------------------------------------------- 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(y, 0, W) { res[y] = ""; rep(x, 0, H) res[y] += C[H - 1 - x][y]; } return res; } if (R == 180) { vector res(H); rep(y, 0, H) { res[y] = ""; rep(x, 0, W) res[y] += C[H - 1 - y][W - 1 - x]; } return res; } if (R == 270) { vector res(W); rep(y, 0, W) { res[y] = ""; rep(x, 0, H) res[y] += C[x][W - 1 - y]; } return res; } return C; } //--------------------------------------------------------------------------------------------------- vector scale(vector C, int K) { int H = C.size(); int W = C[0].size(); vector res(H * K); rep(y, 0, H * K) rep(x, 0, W * K) res[y] += C[y / K][x / K]; return res; } //--------------------------------------------------------------------------------------------------- void _main() { int R, K, H, W; cin >> R >> K >> H >> W; vector C(H); rep(y, 0, H) cin >> C[y]; C = rotate(C, R); C = scale(C, K); print(C); }