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