#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000005;
const double eps = 1e-11;
const long long mod = 1e9 + 7;
char cade[105][105], rot[105][105], ans[1005][1005];
int n, m;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> cade[i];
  }
  int ii = 0, jj = 0;
  for (int j = 0; j < n; j++) {
    for (int i = m - 1; i >= 0; i--) {
      rot[ii][jj] = cade[i][j];
      jj++;
    }
    rot[ii][jj] = '\0';
    ii++;
    jj = 0;
  }
  ii = 0;
  jj = m - 1;
  while (ii < jj) {
    for (int i = 0; i < n; i++) {
      swap(rot[i][ii], rot[i][jj]);
    }
    ii++;
    jj--;
  }
  ii = 0;
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      ans[i][ii] = rot[i][j];
      ans[i][ii + 1] = rot[i][j];
    }
    ii += 2;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2 * m; j++) {
      cout << ans[i][j];
    }
    cout << endl;
    for (int j = 0; j < 2 * m; j++) {
      cout << ans[i][j];
    }
    cout << endl;
  }
}
