#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, w, h;
  string temp;
  vector<string> img;
  cin >> w >> h;
  for (i = 0; i < h; i++) {
    cin >> temp;
    img.push_back(temp);
  }
  for (j = 0; j < w; j++) {
    for (i = 0; i < h; i++) cout << img[i][j] << img[i][j];
    cout << endl;
    for (i = 0; i < h; i++) cout << img[i][j] << img[i][j];
    cout << endl;
  }
  return 0;
}
