#include <bits/stdc++.h>
using namespace std;
char a[1000][1000];
int main() {
  int w, h;
  scanf("%d%d", &w, &h);
  char x;
  scanf("%c", &x);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      scanf("%c", &c);
      a[i][j] = c;
    }
    char c;
    scanf("%c", &c);
  }
  for (int i = 0; i < w; i++) {
    for (int k = 0; k < 2; k++) {
      for (int j = 0; j < h; j++) {
        printf("%c", a[j][i]);
        printf("%c", a[j][i]);
      }
      printf("\n");
    }
  }
  return 0;
}
