#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
const int DEL = 687134561;
const long long MODULO = 1e9 + 7;
const int MAX = 1e7;
const int des = 10000;
int main() {
  int w, h;
  cin >> h >> w;
  char mass[200][200], ans1[200][200], ans2[200][200], ans3[200][200];
  for (int i = 0; i < w; i++) {
    for (int z = 0; z < h; z++) {
      cin >> mass[i][z];
    }
  }
  for (int i = 0; i < w; i++) {
    for (int z = 0; z < h; z++) {
      ans1[z][i] = mass[i][z];
    }
  }
  for (int i = 0; i < w; i++) {
    for (int z = 0; z < h; z++) {
      ans2[z * 2][i * 2] = ans1[z][i];
      ans2[z * 2 + 1][i * 2] = ans1[z][i];
      ans2[z * 2][i * 2 + 1] = ans1[z][i];
      ans2[z * 2 + 1][i * 2 + 1] = ans1[z][i];
    }
  }
  for (int i = 0; i < 2 * h; i++) {
    for (int z = 0; z < 2 * w; z++) {
      cout << ans2[i][z];
    }
    cout << endl;
  }
}
