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