#include <bits/stdc++.h>
using namespace std;
vector<vector<char> > arr;
vector<vector<char> > arr1;
vector<vector<char> > arrAns;
int n, m, h, w;
char ch;
int main() {
  scanf("%d%d", &h, &w);
  arr.resize(w);
  arr1.resize(h);
  arrAns.resize(h * 2);
  for (int i = 0; i < w; i++)
    for (int j = 0; j < h; j++) {
      cin >> ch;
      arr[i].push_back(ch);
      arr1[j].resize(w);
    }
  for (int i = 0; i < w; i++)
    for (int j = 0; j < h; j++) arr1[h - j - 1][i] = arr[i][j];
  for (int i = 0; i < h / 2; i++)
    for (int j = 0; j < w; j++) swap(arr1[i][j], arr1[h - i - 1][j]);
  for (int i = 0; i < h * 2; i++) arrAns[i].resize(w * 2);
  int ik = -1, jk = -1;
  for (int i = 0; i < h; i++) {
    jk = -1;
    ik++;
    for (int j = 0; j < w; j++) {
      jk++;
      arrAns[ik][jk] = arr1[i][j];
      jk++;
      arrAns[ik][jk] = arr1[i][j];
    }
    jk = -1;
    ik++;
    for (int j = 0; j < w; j++) {
      jk++;
      arrAns[ik][jk] = arr1[i][j];
      jk++;
      arrAns[ik][jk] = arr1[i][j];
    }
  }
  for (int i = 0; i < h * 2; i++) {
    for (int j = 0; j < w * 2; j++) cout << arrAns[i][j];
    cout << endl;
  }
  return 0;
}
