#include <bits/stdc++.h>
int w, h, buf;
char image[201][201];
int main() {
  std::cin >> w >> h;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      std::cin >> image[j][i];
    }
  }
  buf = w;
  w = h;
  h = buf;
  for (int i = w - 1, l = w * 2 - 1; i >= 0; --i) {
    for (int k = 0; k < 2; ++k) {
      for (int j = 0; j < h; ++j) {
        image[j][l] = image[j][i];
      }
      l--;
    }
  }
  w = w * 2;
  for (int i = h - 1, l = h * 2 - 1; i >= 0; --i) {
    for (int k = 0; k < 2; ++k) {
      for (int j = 0; j < w; ++j) {
        image[l][j] = image[i][j];
      }
      l--;
    }
  }
  h = h * 2;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      std::cout << image[i][j];
    }
    std::cout << "\n";
  }
  return 0;
}
