#include <bits/stdc++.h>
using namespace std;
char a[204][204], b[204][204], g;
int h, i, j, w, k, u, l, m;
int main() {
  cin >> w >> h;
  for (i = 1; i <= h; i++) {
    for (j = 1; j <= w; j++) cin >> a[i][j];
  }
  for (i = 1; i <= h; i++)
    for (j = 1; j <= w; j++) {
      b[j][h - i + 1] = a[i][j];
    }
  if (h % 2 == 1) u = 1;
  k = u;
  for (j = 1; j <= w; j++) {
    for (i = h / 2; i >= 1; i--) {
      k++;
      g = b[j][h / 2 + k];
      b[j][h / 2 + k] = b[j][i];
      b[j][i] = g;
    }
    k = u;
  }
  for (i = 1; i <= 2 * w; i += 2) {
    m++;
    for (j = 1; j <= 2 * h; j += 2) {
      l++;
      a[i][j] = b[m][l];
      a[i][j + 1] = b[m][l];
      a[i + 1][j + 1] = b[m][l];
      a[i + 1][j] = b[m][l];
    }
    l = 0;
  }
  for (i = 1; i <= 2 * w; i++) {
    for (j = 1; j <= 2 * h; j++) cout << a[i][j];
    cout << endl;
  }
  return 0;
}
