#include <bits/stdc++.h>
using namespace std;
int w, h;
char m[201][201];
char scaled[402][402];
void operation_1_2() {
  int sz = max(w, h);
  for (int i = 0; i < sz; ++i) {
    for (int j = 0; j <= i; ++j) {
      swap(m[i][j], m[j][i]);
    }
  }
}
void scale(int w, int h) {
  int ii = 0, jj;
  for (int i = 0; i < h; ++i) {
    jj = 0;
    for (int j = 0; j < w; ++j) {
      scaled[ii][jj++] = m[i][j];
      scaled[ii][jj++] = m[i][j];
    }
    ii++;
    for (int j = 0; j < 2 * w; ++j) {
      scaled[ii][j] = scaled[ii - 1][j];
    }
    ii++;
  }
}
void print(int w, int h) {
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << m[i][j];
    }
    cout << endl;
  }
}
void print2(int w, int h) {
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << scaled[i][j];
    }
    cout << endl;
  }
}
int main(int argc, const char* argv[]) {
  cin >> w >> h;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> m[i][j];
    }
  }
  operation_1_2();
  scale(h, w);
  print2(2 * h, 2 * w);
  return 0;
}
