#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  char c;
  cin >> w >> h;
  string* m = new string[h];
  string* n = new string[2 * w];
  string t;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> c;
      m[i] += c;
    }
  }
  for (int j = 0; j < w * 2; j += 2) {
    t = "";
    for (int k = h - 1; k >= 0; --k) t += m[k][j / 2];
    for (int i = t.size() - 1; i >= 0; --i) {
      n[j] += t[i];
      n[j] += t[i];
    }
  }
  for (int i = 1; i < (2 * w); i += 2) n[i] += n[i - 1];
  for (int i = 0; i < (2 * w); ++i) cout << n[i] << endl;
  return 0;
}
