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