#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, w, w1;
  char a[201][201];
  cin >> w >> w1;
  n = w1;
  m = w;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      cout << a[j][i] << a[j][i];
    }
    cout << endl;
    for (j = 1; j <= n; j++) {
      cout << a[j][i] << a[j][i];
    }
    cout << endl;
  }
  return 0;
}
