#include using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define all(x) (x).begin(),(x).end() #define foreach(u,v) for(auto (u) : (v)) #define pb push_back #define mp make_pair #define mt make_tuple typedef long long ll; typedef pair pii; typedef vector vi; typedef vector vvi; typedef pair pll; typedef vector vl; const int inf = 1e9; const ll linf = 1LL<<60; const ll mod = 1e9 + 7; const double eps = 1e-9; /* */ vvi rotate(vvi v) { int h = v.size(); int w = v[0].size(); vvi u(w, vi(h)); rep(i, h) rep(j, w){ u[j][i] = v[i][j]; } return u; } vvi expand(vvi v, int m) { int h = v.size(); int w = v[0].size(); vvi u(h*m, vi(m*w)); rep(i, h*m) rep(j, w*m){ u[i][j] = v[i/m][j/m]; } return u; } int main() { int r, k, h, w; cin >> r >> k >> h >> w; vvi c(h, vi(w)); rep(i, h){ string s; cin >> s; rep(j, w){ c[i][j] = s[j]; } } vvi d = c; rep(i, r/90) d = rotate(d); vvi ans = expand(d, k); rep(i, ans.size()){ rep(j, ans[0].size()){ printf("%c", ans[i][j]); } printf("\n"); } return 0; }