#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, m;
  string s;
  char a[323][323], b[323][323];
  cin >> m >> n;
  for (i = 0; i < n; i++) {
    cin >> s;
    for (j = 0; j < m; j++) a[i][j] = s[j];
  }
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++) {
      b[i][j] = a[n - j - 1][i];
    }
  for (i = 0; i < m; i++) {
    for (j = n - 1; j >= 0; j--) cout << b[i][j] << b[i][j];
    cout << "\n";
    for (j = n - 1; j >= 0; j--) cout << b[i][j] << b[i][j];
    cout << "\n";
  }
}
