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