#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  cin >> w >> h;
  char a[h][w];
  char b[w][h];
  char c[2 * w][2 * h];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      b[j][i] = a[i][j];
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      c[2 * i][2 * j] = b[i][j];
      c[2 * i][2 * j + 1] = b[i][j];
      c[2 * i + 1][2 * j] = b[i][j];
      c[2 * i + 1][2 * j + 1] = b[i][j];
    }
  }
  for (int i = 0; i < (2 * w); i++) {
    for (int j = 0; j < (2 * h); j++) {
      cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}
