#include <bits/stdc++.h>
using namespace std;
int w, h, i, j;
char Image[100 + 1][100 + 1];
void ReadImage() {
  cin >> w >> h;
  for (i = 1; i <= h; i++) {
    for (j = 1; j <= w; j++) {
      cin >> Image[i][j];
    }
  }
}
char first[100 + 1][100 + 1];
void First() {
  for (j = 1; j <= h; j++) {
    for (i = 1; i <= w; i++) {
      first[i][j] = Image[j][i];
    }
  }
  swap(w, h);
}
void Second() {
  for (i = 1; i <= h; i++) {
    for (j = 1; j <= w; j++) {
      Image[i][j] = first[i][w - j + 1];
    }
  }
}
void Third() {
  char answer[2 * 100 + 1][2 * 100 + 1];
  int i1, j1;
  for (i = 1; i <= h; i++) {
    for (j = 1; j <= w; j++) {
      i1 = i * 2 - 1;
      j1 = j * 2 - 1;
      answer[i1][j1] = answer[i1][j1 + 1] = answer[i1 + 1][j1] =
          answer[i1 + 1][j1 + 1] = first[i][j];
    }
  }
  for (i = 1; i <= 2 * h; i++) {
    for (j = 1; j <= 2 * w; j++) {
      cout << answer[i][j];
    }
    cout << "\n";
  }
}
int main() {
  ReadImage();
  First();
  Second();
  Third();
  return 0;
}
