#include <bits/stdc++.h>
using namespace std;
int w, h;
char mas[500][500];
char mas90[500][500];
int main() {
  scanf("%d%d", &w, &h);
  for (int i = 0; i < h; i++) {
    scanf("%s", mas[i]);
  }
  for (int i = 0; i < w; i++) {
    for (int j = h - 1; j >= 0; j--) {
      mas90[i][j] = mas[j][i];
    }
  }
  for (int i = 0; i < w; i++) {
    string temp = "";
    int ptr = 0;
    for (int j = 0; j < h; j++) {
      temp += mas90[i][j];
      temp += mas90[i][j];
    }
    cout << temp << endl << temp << endl;
  }
}
