#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string sInput;
  vector<string> arrInput;
  int iHeight, iLength;
  register int i, j;
  cin >> iLength >> iHeight;
  for (i = 1; i <= iHeight; ++i) {
    cin >> sInput;
    arrInput.push_back(sInput);
  }
  for (i = 0; i < iLength; ++i) {
    sInput = "";
    for (j = 0; j < iHeight; ++j) {
      sInput += arrInput[j][i];
      sInput += arrInput[j][i];
    }
    cout << sInput << endl << sInput << endl;
  }
  return 0;
}
