#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> w;
  std::cin >> h;
  char** mas = new char*[2 * w];
  for (int i = 0; i < 2 * w; i++) {
    mas[i] = new char[2 * h];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char a;
      cin >> a;
      mas[j * 2][i * 2] = a;
      mas[j * 2 + 1][i * 2] = a;
      mas[j * 2][i * 2 + 1] = a;
      mas[j * 2 + 1][i * 2 + 1] = a;
    }
  }
  for (int i = 0; i < 2 * w; i++) {
    for (int g = 0; g < 2 * h; g++) {
      cout << mas[i][g];
    }
    cout << "\n";
  }
}
