#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[300][300], b[300][300];
  int i, j, x, y, n, m;
  cin >> x >> y;
  x--;
  y--;
  for (j = 0; j <= y; j++)
    for (i = 0; i <= x; i++) cin >> a[i][j];
  for (i = 0; i <= x; i++)
    for (j = 0; j <= y; j++) b[y - j][i] = a[i][j];
  swap(x, y);
  for (j = 0; j <= y; j++)
    for (i = 0; i <= x / 2; i++) swap(b[i][j], b[x - i][j]);
  x = x * 2 + 1;
  y = y * 2 + 1;
  for (i = 0; i <= x; i += 2)
    for (j = 0; j <= y; j += 2)
      a[i][j] = a[i + 1][j] = a[i + 1][j + 1] = a[i][j + 1] = b[i / 2][j / 2];
  for (j = 0; j <= y; j++) {
    for (i = 0; i <= x; i++) cout << a[i][j];
    if (j < y) cout << endl;
  }
  return 0;
}
