#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const* argv[]) {
  int w, h;
  string a;
  string b = "";
  cin >> w >> h;
  vector<string> c;
  for (int i = 0; i < h; i++) {
    cin >> a;
    for (int j = 0; j < a.size(); j++) {
      b += a[j];
      b += a[j];
    }
    c.push_back(b);
    c.push_back(b);
    b = "";
  }
  for (int i = 0; i < 2 * w; i += 1) {
    for (int j = 0; j < 2 * h; j += 1) {
      cout << c[j][i];
    }
    cout << "\n";
  }
  return 0;
}
