#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  char a[250][250];
  char s[250][250];
  memset(s, 0, sizeof(s));
  while (scanf("%d%d", &w, &h) != EOF) {
    for (int i = 0; i < h; i++) {
      scanf("%s", &a[i]);
    }
    for (int i = 0; i < h; i++) {
      int l = 0;
      for (int j = 0; j < w; j++) {
        s[j][i] = a[i][j];
      }
    }
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        printf("%c%c", s[i][j], s[i][j]);
      }
      printf("\n");
      for (int j = 0; j < h; j++) {
        printf("%c%c", s[i][j], s[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}
