#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  cin >> w >> h;
  vector<string> Input(h);
  for (int i = 0; i < h; i++) {
    cin >> Input[i];
  }
  vector<string> Output(w);
  for (int i = 0; i < w; i++) {
    Output[i].resize(h);
    for (int j = h - 1; j >= 0; j--) Output[i][h - 1 - j] = Input[j][i];
  }
  for (int i = 0; i < w; i++) {
    int l = 0, r = h - 1;
    while (l < r) {
      swap(Output[i][l], Output[i][r]);
      l++;
      r--;
    }
  }
  vector<string> Ans(2 * w);
  for (int i = 0; i < w; i++) {
    Ans[2 * i].resize(2 * h);
    Ans[2 * i + 1].resize(2 * h);
    for (int j = 0; j < h; j++)
      Ans[2 * i][2 * j] = Ans[2 * i][2 * j + 1] = Ans[2 * i + 1][2 * j] =
          Ans[2 * i + 1][2 * j + 1] = Output[i][j];
  }
  for (int i = 0; i < 2 * w; i++) cout << Ans[i] << endl;
  return 0;
}
