#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(int i = m;i >= n;--i) #define INF INT_MAX/2 using namespace std; using ll = long long; using R = double; using Data = pair>; const ll MOD = 1e9 + 7; const ll inf = 1LL << 50; struct edge { ll from; ll to; ll cost; }; int r, k, h, w; vectorss; char final[1000][1000]; vector> zoom(vectortemp,int h,int w,int z) { vector>ret(z*h,vector(z*w)); rep(i, 0, h)rep(j, 0, w) { for (int p = k * i; p <= k * (i + 1) - 1; p++) { for (int q = k * j; q <= k * (j + 1) - 1; q++) { ret[p][q]=temp[i][j]; } } } return ret; } vector> rotate(vector>temp, int h, int w) { vector>ret(w, vector(h)); rep(i, 0, w)rep(j, 0, h) { ret[i][j] = temp[h-j-1][i]; } return ret; } int main() { cin >> r >> k >> h >> w; rep(i, 0, h) { string s; cin >> s; ss.pb(s); } vector>zm = zoom(ss,h,w,k); vector>ans = zm; rep(i, 0, r / 90) { ans = rotate(ans, ans.size(), ans[0].size()); } rep(i, 0, ans.size()) { rep(j, 0, ans[0].size()) { cout << ans[i][j]; } cout << endl; } return 0; }