#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
const int INF = 1000000000, mod = 1000000007;
const long long LLINF = 1000000000000000000ll;
int main() {
  int n, m;
  scanf("%d%d\n", &m, &n);
  vector<vector<char> > v(n, vector<char>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      v[i][j] = getchar();
    }
    if (i < n - 1) getchar();
  }
  vector<vector<char> > a(m, vector<char>(n));
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      a[i][n - 1 - j] = v[j][i];
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n / 2; ++j) {
      swap(a[i][j], a[i][n - j - 1]);
    }
  }
  vector<vector<char> > b(2 * m, vector<char>(2 * n));
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      b[2 * i][2 * j] = b[2 * i + 1][2 * j + 1] = b[2 * i][2 * j + 1] =
          b[2 * i + 1][2 * j] = a[i][j];
    }
  }
  for (int i = 0; i < 2 * m; ++i) {
    for (int j = 0; j < 2 * n; ++j) {
      putchar(b[i][j]);
    }
    putchar('\n');
  }
  return 0;
}
