#include using namespace std; char hoge[15][15], ans[105][105]; int main() { cin.tie(0); ios::sync_with_stdio(false); int R, K, H, W; cin >> R >> K >> H >> W; for (int i = 0; i < H; i++) { string s; cin >> s; for (int j = 0; j < W; j++) { if (R == 0) hoge[i][j] = s[j]; else if (R == 90) hoge[j][H - i - 1] = s[j]; else if (R == 180) hoge[H - i - 1][W - j - 1] = s[j]; else hoge[W - j - 1][i] = s[j]; } } if (R / 90 % 2) swap(H, W); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { for (int k = 0; k < K; k++) { for (int l = 0; l < K; l++) { ans[i * K + k][j * K + l] = hoge[i][j]; } } } } for (int i = 0; i < H * K; i++) { for (int j = 0; j < W * K; j++) { cout << ans[i][j]; } cout << endl; } return 0; }