#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 zoom[1000][1000]; char final[1000][1000]; int main() { cin >> r >> k >> h >> w; rep(i, 0, h) { string s; cin >> s; ss.pb(s); } rep(i, 0, 1000)rep(j, 0, 1000)zoom[i][j] = 'x'; 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++) { zoom[p][q] = ss[i][j]; } } } if (r == 90) { rep(i, 0, k*w)rep(j, 0, k*h) { final[i][j] = zoom[k*h-j-1][i]; } rep(i, 0, k*w) { rep(j, 0, k*h) { cout << final[i][j]; } cout << endl; } } else if (r == 180) { rep(i, 0, k*h)rep(j, 0, k*w) { final[i][j] = zoom[k*h-i-1][k*w-j-1]; } rep(i, 0, k*h) { rep(j, 0, k*w) { cout << final[i][j]; } cout << endl; } } else if (r == 270) { rep(i, 0, k*w)rep(j, 0, k*h) { final[i][j] = zoom[j][k*w-i-1]; } rep(i, 0, k*w) { rep(j, 0, k*h) { cout << final[i][j]; } cout << endl; } } return 0; }