#include "bits/stdc++.h" #define REP(i,n,N) for(int i=(n); i<(N); i++) #define RREP(i,n,N) for(int i=(N-1); i>=n; i--) #define CK(n,a,b) (a)<=(n)&&(n)<(b) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)< rota(vector v) { int y = v.size(), x = v[0].size(); vector ret; for(int i=0;i expand(vector vt) { vector vs, ret; for(auto v:vt){ REP(i,0,K) vs.push_back(v); } for(auto v:vs){ string tmp; for(auto r:v){ REP(i,0,K) tmp+=r; } ret.push_back(tmp); } return ret; } int main(){ while(cin>>R>>K>>H>>W){ vector vt, ans; string s; REP(i,0,H){ cin>>s; vt.push_back(s); } REP(i,0,R/90){ vt = rota(vt); } ans = expand(vt); for(auto a:ans){ p(a); } } }