#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  cin >> w >> h;
  vector<vector<char> > a;
  a.resize(w);
  for (auto i = 0; i < w; ++i) {
    a[i].resize(h);
  }
  for (auto i = 0; i < h; ++i) {
    for (auto j = 0; j < w; ++j) {
      cin >> a[j][i];
    }
  }
  w <<= 1;
  h <<= 1;
  for (auto i = 0; i < w; ++i) {
    for (auto j = 0; j < h; ++j) {
      int ind_i = i >> 1, ind_j = j >> 1;
      cout << a[ind_i][ind_j];
    }
    cout << endl;
  }
}
