#include using namespace std; using ll = long long; int N, K; string S[10]; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> K; for(int i = 0;i < N;i++)cin >> S[i]; for(int i = 0;i < N * K;i++){ for(int j = 0;j < N * K;j++){ cout << S[i / K][j / K]; } cout << "\n"; } return 0; }