#include #include #include using namespace std; using ll = long long int; #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define PREPARED_ENVIRONMENT template std::ostream& operator<<(std::ostream& o, const std::vector& v) { o << "{"; for (int i = 0; i < (int) v.size(); i++) o << (i > 0 ? ", " : "" ) << v[i]; o << "}"; return o; } // std::ostream& operator<<(std::ostream& o, const std::vector& v) { // o << "{ "; // for (int i = 0; i < (int) v.size(); i++) // o << (i > 0 ? "\n, " : "" ) << v[i]; // o << " }"; // return o; // } template std::ostream& operator<<(std::ostream& o, const std::pair& p) { o << "(" << p.first << ", " << p.second << ")"; return o; } int r, k, h, w; vector rotate(const vector& plan) { int h = plan.size(); int w = plan[0].size(); vector res(w, string(h, ' ')); REP(i, h) { REP(j, w) { res[j][h-1-i] = plan[i][j]; } } return res; } vector expand(const vector& plan, int ratio) { int h = plan.size(); int w = plan[0].size(); int newh = h * ratio; int neww = w * ratio; vector res(newh, string(neww, ' ')); REP(i, newh) { REP(j, neww) { res[i][j] = plan[i/ratio][j/ratio]; } } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> r >> k >> h >> w; cin.ignore(); vector plan(h); string s; REP(i, h) { getline(cin, s); plan[i] = s; } REP(i, r/90) { plan = rotate(plan); } plan = expand(plan, k); REP(i, plan.size()) { cout << plan[i] << "\n"; } return 0; }