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