#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  scanf("%d %d", &w, &h);
  vector<vector<char> > matrix(w + 1, vector<char>(h + 1)),
      tmatrix(2 * w + 1, vector<char>(2 * h + 1));
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> matrix[j][i];
    }
  }
  int I, J;
  I = 1;
  J = 1;
  for (int i = 1; i <= w; i++) {
    J = 1;
    for (int j = 1; j <= h; j++) {
      tmatrix[I][J] = matrix[i][j];
      tmatrix[I][J + 1] = matrix[i][j];
      tmatrix[I + 1][J] = matrix[i][j];
      tmatrix[I + 1][J + 1] = matrix[i][j];
      J += 2;
    }
    I += 2;
  }
  for (int i = 1; i <= 2 * w; i++) {
    for (int j = 1; j <= 2 * h; j++) {
      cout << tmatrix[i][j];
    }
    cout << endl;
  }
}
