#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> #include <cstring> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; typedef pair<int, int> P; int main() { ios::sync_with_stdio(false); cin.tie(0); int R, K; cin >> R >> K; int H, W; cin >> H >> W; vector<string> vs(H); FOR(i,0,H) cin >> vs[i]; map<P, P> MAP; FOR(i,1,W+1) FOR(j,1,H+1) MAP[P(i, j)] = P(i, j); R /= 90; FOR(i,0,R) { for(auto m : MAP) { int x = m.second.first; int y = m.second.second; int X = y; int Y = x; MAP[m.first] = P(X, Y); } } int w = W, h = H; if(R == 1 || R == 3) { w = H; h = W; } vector<string> fig(h, string(w, 'a')); for(auto m : MAP) { int x = m.first.first-1; int y = m.first.second-1; int X = m.second.first-1; int Y = m.second.second-1; fig[Y][X] = vs[y][x]; } FOR(i,0,h) { FOR(k,0,K) { FOR(j,0,w) { FOR(l,0,K) { cout << fig[i][j]; } } cout << endl; } } return 0; }