// github.com/Johniel/contests // yukicoder/2728/main.cpp #include #define each(i, c) for (auto& i : c) #define unless(cond) if (!(cond)) #define makepair(a, b) make_pair(a, b) // #define endl "\n" using namespace std; template ostream& operator << (ostream& os, pair p); template istream& operator >> (istream& is, pair& p); template ostream& operator << (ostream& os, tuple t) { os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")"; return os; } template istream& operator >> (istream& is, tuple& t) { is >> get<0>(t) >> get<1>(t) >> get<2>(t); return is; } template ostream& operator << (ostream& os, vector v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; } template istream& operator >> (istream& is, vector& v) { for (auto& i: v) is >> i; return is; } template ostream& operator << (ostream& os, set s) { os << "set{"; for (auto& i: s) os << i << ","; os << "}"; return os; } template ostream& operator << (ostream& os, map m) { os << "map{"; for (auto& i: m) os << i << ","; os << "}"; return os; } template istream& operator >> (istream& is, array& a) { for (auto& i: a) is >> i; return is; } template ostream& operator << (ostream& os, array& a) { os << "[" << N << "]{"; for (auto& i: a) os << i << ","; os << "}"; return os; } template ostream& operator << (ostream& os, stack s) { os << "stack{"; while (s.size()) { os << s.top() << ","; s.pop(); } os << "}"; return os; } template ostream& operator << (ostream& os, queue q) { os << "queue{"; while (q.size()) { os << q.front() << ","; q.pop(); } os << "}"; return os; } template ostream& operator << (ostream& os, deque q) { os << "deque{"; for (int i = 0; i < q.size(); ++i) os << q[i] << ","; os << "}"; return os; } template ostream& operator << (ostream& os, priority_queue q) { os << "heap{"; while (q.size()) { os << q.top() << ","; q.pop(); } os << "}"; return os; } template ostream& operator << (ostream& os, pair p) { os << "(" << p.first << "," << p.second << ")"; return os; } template istream& operator >> (istream& is, pair& p) { is >> p.first >> p.second; return is; } template inline T setmax(T& a, T b) { return a = std::max(a, b); } template inline T setmin(T& a, T b) { return a = std::min(a, b); } __attribute__((constructor)) static void _____(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.setf(ios_base::fixed); cout.precision(15); return ; } using lli = long long int; using ull = unsigned long long; using str = string; template using vec = vector; // constexpr lli mod = 1e9 + 7; constexpr lli mod = 998244353; int main(int argc, char *argv[]) { int n, k; while (cin >> n >> k) { char g[n*k][n*k]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { char c; cin >> c; for (int a = 0; a < k; ++a) { for (int b = 0; b < k; ++b) { g[i * k + a][j * k + b] = c; } } } } for (int i = 0; i < n * k; ++i) { for (int j = 0; j < n * k; ++j) { cout << g[i][j]; } cout << endl; } } return 0; }