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