#include #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)n;++i) #define each(a,b) for(auto (a): (b)) #define all(v) (v).begin(),(v).end() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<P; const int MAX_N = 15; char s[MAX_N][MAX_N]; string t[MAX_N]; char ss[MAX_N*MAX_N][MAX_N*MAX_N]; int main() { cin.tie(0); ios::sync_with_stdio(false); int r,K,h,w; cin >> r >> K >> h >> w; rep(i,h){ cin >> t[i]; } int nh,nw; if(r == 0){ nh = h,nw = w; rep(i,nh){ rep(j,nw){ s[i][j] = t[i][j]; } } }else if(r == 90){ nh = w,nw = h; rep(i,nh){ rep(j,nw){ s[i][j] = t[nw-1-j][i]; } } }else if(r == 180){ nh = h,nw = w; rep(i,nh){ rep(j,nw){ s[i][j] = t[nh-1-i][nw-1-j]; } } }else{ nh = w,nw = h; rep(i,nh){ rep(j,nw){ s[i][j] = t[j][nh-1-i]; } } } rep(i,nh){ rep(j,nw){ int sh=K*i,sw=K*j; rep(k,K){ rep(l,K){ ss[sh+k][sw+l] = s[i][j]; } } } } rep(i,K*nh){ rep(j,K*nw){ cout << ss[i][j]; } cout << endl; } return 0; }