#define REP(i,n) for(int i=0; i<(int)(n); i++) #include #include inline int getInt(){ int s; scanf("%d", &s); return s; } #include using namespace std; int main(){ const int r = getInt() / 90; const int k = getInt(); const int h = getInt(); const int w = getInt(); const int n = max(h, w); vector > g(n, vector(n, ' ')); const int ww = r % 2 == 0 ? w : h; const int hh = r % 2 == 0 ? h : w; REP(i,h){ char buff[256]; scanf("%s", buff); REP(j,w) g[i][j] = buff[j]; } REP(_,r){ vector > next(n, vector(n)); REP(i,n) REP(j,n){ next[j][n - 1 - i] = g[i][j]; } g.swap(next); // REP(i,n) { REP(j,n) { printf("%c", g[i][j]); } puts(""); }; // puts("---"); } int oX = n; int oY = n; REP(i,n) REP(j,n) if(g[i][j] != ' ') { oX = min(oX, j); oY = min(oY, i); } // printf("%d %d\n", oX, oY); REP(i,hh) REP(_, k) { REP(j,ww) REP(_, k) { printf("%c", g[oY + i][oX + j]); } puts(""); }; return 0; }