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