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