#include <bits/stdc++.h>
using namespace std;
int w, h;
void turn_right(char** img, char** new_img, int h, int w) {
  for (int i = 0; i < w; ++i)
    for (int j = 0; j < h; ++j) new_img[i][j] = img[j][i];
}
void mirroring(char** img, int h, int w) {
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w / 2; ++j) {
      char buf = img[i][w - 1 - j];
      img[i][w - 1 - j] = img[i][j];
      img[i][j] = buf;
    }
}
void scaling(char** img, char** new_img, int h, int w) {
  int c(0);
  for (int i = 0; i < h; ++i) {
    int k(0);
    for (int j = 0; j < w; ++j) {
      new_img[i + c][j + k] = new_img[i + c][j + 1 + k] =
          new_img[i + 1 + c][j + k] = new_img[i + 1 + c][j + 1 + k] = img[i][j];
      ++k;
    }
    ++c;
  }
}
int main() {
  cin >> w >> h;
  char** img = new char*[h];
  char** new_img = new char*[w];
  char** scale_img = new char*[2 * w];
  for (int i = 0; i < h; ++i) img[i] = new char[w];
  for (int i = 0; i < w; ++i) {
    new_img[i] = new char[h];
    scale_img[i] = new char[2 * h];
  }
  for (int i = w; i < 2 * w; ++i) scale_img[i] = new char[2 * h];
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) cin >> img[i][j];
  turn_right(img, new_img, h, w);
  scaling(new_img, scale_img, w, h);
  for (int i = 0; i < 2 * w; ++i) {
    for (int j = 0; j < 2 * h; ++j) cout << scale_img[i][j];
    cout << endl;
  }
  for (int i = 0; i < h; ++i) delete img[i];
  for (int i = 0; i < w; ++i) {
    delete new_img[i];
    delete scale_img[i];
  }
  for (int i = w; i < 2 * w; ++i) delete scale_img[i];
  return 0;
}
