#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795;
int main() {
  int n, m;
  char a[100][100];
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) cin >> a[j][m - i - 1];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < (m / 2); j++) {
      char c = a[i][j];
      a[i][j] = a[i][m - j - 1];
      a[i][m - j - 1] = c;
    }
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < 2; k++) {
      for (int j = 0; j < m; j++) cout << a[i][j] << a[i][j];
      cout << '\n';
    }
  }
}
