#line 2 "template.hpp" // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #include using namespace std; template concept Streamable = requires(ostream os, T &x) { os << x; }; template concept is_modint = requires(mint &x) { { x.val() } -> std::convertible_to; }; #ifdef LOCAL #include #else #define debug(...) #endif template void print_one(const T &value) { cout << value; } template void print_one(const T &value) { cout << value.val(); } void print() { cout << '\n'; } template void print(const T &a, const Ts &...b) { print_one(a); ((cout << ' ', print_one(b)), ...); cout << '\n'; } template requires(!Streamable) void print(const Iterable &v) { for(auto it = v.begin(); it != v.end(); ++it) { if(it != v.begin()) cout << " "; print_one(*it); } cout << '\n'; } using ll = long long; using vi = vector; using vii = vector>; using pii = pair; using vl = vector; using vll = vector; using pll = pair; #define all(v) begin(v), end(v) #define UNIQUE(v) ranges::sort(v), v.erase(unique(all(v)), end(v)) template inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } template inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } // https://trap.jp/post/1224/ template constexpr auto min(T... a) { return min(initializer_list>{a...}); } template constexpr auto max(T... a) { return max(initializer_list>{a...}); } template void input(T &...a) { (cin >> ... >> a); } template void input(vector &a) { for(T &x : a) cin >> x; } #define INT(...) \ int __VA_ARGS__; \ input(__VA_ARGS__) #define LL(...) \ long long __VA_ARGS__; \ input(__VA_ARGS__) #define STR(...) \ string __VA_ARGS__; \ input(__VA_ARGS__) #define REP1(a) for(ll i = 0; i < a; i++) #define REP2(i, a) for(ll i = 0; i < a; i++) #define REP3(i, a, b) for(ll i = a; i < b; i++) #define REP4(i, a, b, c) for(ll i = a; i < b; i += c) #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__) #define rep1(i, n) for(ll i = 1; i <= ((ll)n); ++i) ll inf = 3e18; vl dx = {1, -1, 0, 0}; vl dy = {0, 0, 1, -1}; template T floor(T x, T y) { auto d = div(x, y); return d.quot - (x ^ y < 0 and d.rem); } template T ceil(T x, T y) { return floor(x + y - 1, y); } template T remainder(T x, T y) { T m = x % y; return (m < 0) ? m + abs(y) : m; } #line 2 "other/matrix-rotate-expansion.hpp" template vector matrix_rotate(const vector &a, int clockwize_cnt = 1) { if(a.empty()) return vector(); clockwize_cnt = remainder(clockwize_cnt, 4); if(clockwize_cnt == 0) { return a; } using U = typename T::value_type; int h = ssize(a), w = ssize(a[0]); vector res = (clockwize_cnt & 1 ? vector(w, T(h, U())) : vector(h, T(w, U()))); for(int i = 0; i < h; ++i) { for(int j = 0; j < w; ++j) { if(clockwize_cnt == 1) { res[j][h - 1 - i] = a[i][j]; } else if(clockwize_cnt == 3) { res[w - 1 - j][i] = a[i][j]; } else { res[h - 1 - i][w - 1 - j] = a[i][j]; } } } return res; } template vector matrix_expansion(const vector &a, int k) { if(a.empty()) { return vector(); } int h = ssize(a), w = ssize(a[0]); using U = typename T::value_type; vector res(k * h, T(k * w, U())); for(int i = 0; i < h; ++i) { for(int j = 0; j < w; ++j) { for(int s = 0; s < k; ++s) { for(int t = 0; t < k; ++t) { res[k * i + s][k * j + t] = a[i][j]; } } } } return res; } #line 3 "/home/y_midori/cp/a.cpp" int main() { cin.tie(nullptr); ios::sync_with_stdio(false); INT(r, k, h, w); vector c(h); input(c); c = matrix_rotate(c, r / 90); c = matrix_expansion(c, k); for(auto &ci : c) print(ci); }