#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; typedef pair P; int main() { ios::sync_with_stdio(false); cin.tie(0); int R, K; cin >> R >> K; int H, W; cin >> H >> W; vector vs(H); FOR(i,0,H) cin >> vs[i]; map MAP; FOR(i,0,W) FOR(j,0,H) MAP[P(i, j)] = P(i, j); R /= 90; FOR(i,0,R) { for(auto m : MAP) { int X = H - m.second.second - 1; int Y = m.second.first; MAP[m.first] = P(X, Y); } } int w = W, h = H; if(R == 1 || R == 3) { w = H; h = W; } vector fig(h, string(w, 'a')); for(auto m : MAP) { int x = m.first.first; int y = m.first.second; int X = m.second.first; int Y = m.second.second; fig[Y][X] = vs[y][x]; } FOR(i,0,h) { FOR(k,0,K) { FOR(j,0,w) { FOR(l,0,K) { cout << fig[i][j]; } } cout << endl; } } return 0; }