#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0; i=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector VI; typedef vector VL; typedef vector VVI; typedef vector VVL; typedef pair P; typedef pair PL; vector rotate(vector s){ int n = s.size(); int m = s[0].size(); vector ret(m); REP(i,m){ REP(j,n){ ret[i] += s[n-1-j][i]; } } return ret; } int main(){ int r, k, h, w; cin >> r >> k >> h >> w; vector s(h); REP(i,h) cin >> s[i]; REP(_,r/90) s = rotate(s); h = s.size(); w = s[0].size(); vector ans(k*h, string(k*w, '0')); REP(i,h) REP(j,w){ FOR(ii,i*k,(i+1)*k-1) FOR(jj,j*k,(j+1)*k-1) ans[ii][jj] = s[i][j]; } for (string t : ans) cout << t << endl; return 0; }