#include using namespace std; //#define int long long #define FOR(i, j, k) for(int i = j; i < k; ++i) #define rep(i, j) FOR(i, 0, j) #define INF (1 << 30) typedef unsigned long long ull; typedef pair P; typedef pair Pi; const int MOD = 1e9 + 7; const int dy[] = {0, 0, 1, -1}; const int dx[] = {1, -1, 0, 0}; template void chmin(T& a, const T& b) { a = min(a, b); } template void chmax(T& a, const T& b) { a = max(a, b); } signed main() { cin.tie(0); ios::sync_with_stdio(false); int r, k, h, w; cin >> r >> k >> h >> w; string s[10]; rep(i, h) cin >> s[i]; if(r == 0 || r == 180) { rep(i, h) rep(hk, k) { rep(j, w) rep(wk, k) { if(r == 0) cout << s[i][j]; else cout << s[h - i - 1][w - j - 1]; } cout << "\n"; } } else { rep(i, w) rep(wk, k) { rep(j, h) rep(hk, k) { if(r == 90) cout << s[h - j - 1][i]; else cout << s[j][w - i - 1]; } cout << "\n"; } } return 0; }