#include <bits/stdc++.h>
using namespace std;
void showT(vector<string> &M, int w, int h) {
  for (int i = 0; i < w; i++) {
    for (int j = h - 1; j > -1; j--) {
      cout << M[j][i];
    }
    cout << endl;
  }
}
void show(vector<string> &M, int h, int w) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << M[i][j];
    }
    cout << endl;
  }
}
int main() {
  int w;
  int h;
  cin >> w;
  cin >> h;
  vector<string> text;
  text.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> text[i];
  }
  if (h % 2 == 0) {
    string swap;
    for (int i = 0; i < h / 2; i++) {
      swap = text[i];
      text[i] = text[h - i - 1];
      text[h - i - 1] = swap;
    }
  } else {
    string swap;
    for (int i = 0; i < h / 2; i++) {
      swap = text[i];
      text[i] = text[h - i - 1];
      text[h - i - 1] = swap;
    }
  }
  vector<string> RES;
  RES.reserve(2 * w);
  for (int i = 0; i < 2 * w; i++) {
    RES.push_back("");
  }
  for (int i = 0; i < w; i++) {
    for (int j = h - 1; j > -1; j--) {
      RES[2 * i].push_back(text[j][i]);
      RES[2 * i].push_back(text[j][i]);
      RES[2 * i + 1].push_back(text[j][i]);
      RES[2 * i + 1].push_back(text[j][i]);
    }
  }
  for (int i = 0; i < RES.size(); i++) {
    cout << RES[i] << endl;
  }
  return 0;
}
