#include <bits/stdc++.h>
using namespace std;
class Picture {
  vector<string>* v;
  int orient;

 public:
  Picture(int w, int h) {
    orient = 0;
    v = new vector<string>;
    string s;
    for (int i = 0; i < h; i++) {
      cin >> s;
      v->push_back(s);
    }
  }
  Picture& turned() {
    orient = (orient + 1) % 4;
    return *this;
  }
  Picture& reflected() {
    if (orient % 2) {
      reverse(v->begin(), v->end());
    } else {
      for (int i = 0; i < v->size(); i++) {
        reverse((*v)[i].begin(), (*v)[i].end());
      }
    }
    return *this;
  }
  Picture& stretched(int scale = 2) {
    vector<string>* copy_v = new vector<string>;
    for (long i = 0; i < v->size(); i++) {
      string copy_s = "";
      for (long j = 0; j < (*v)[0].size(); j++) {
        for (int k = 0; k < scale; k++) {
          copy_s = copy_s + (*v)[i][j];
        }
      }
      for (int k = 0; k < scale; k++) {
        copy_v->push_back(copy_s);
      }
    }
    v = copy_v;
    return *this;
  }
  void print() {
    if (orient == 0) {
      unsigned long h = v->size();
      for (int i = 0; i < h; i++) {
        cout << (*v)[i] << endl;
      }
    } else if (orient == 1) {
      unsigned long h = (*v)[0].size();
      unsigned long w = v->size();
      for (int i = 0; i < h; i++) {
        for (long j = w - 1; j >= 0; j--) {
          cout << (*v)[j][i];
        }
        cout << endl;
      }
    } else if (orient == 2) {
      unsigned long h = v->size();
      unsigned long w = (*v)[0].size();
      for (long i = h - 1; i >= 0; i--) {
        for (long j = w - 1; j >= 0; j--) {
          cout << (*v)[i][j];
        }
        cout << endl;
      }
    } else if (orient == 3) {
      unsigned long h = (*v)[0].size();
      unsigned long w = v->size();
      for (long i = h - 1; i >= 0; i--) {
        for (long j = 0; j < w; j++) {
          cout << (*v)[j][i];
        }
        cout << endl;
      }
    }
  }
};
int main() {
  int w, h;
  cin >> w >> h;
  Picture p(w, h);
  p.turned().reflected().stretched().print();
}
