#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print_picture(const vector<vector<T> >& arr) {
  for (size_t i = 0; i < arr.size(); ++i) {
    for (int j = 0; j < arr[i].size(); ++j) {
      cout << arr[i][j];
    }
    cout << endl;
  }
}
int main() {
  int w, h;
  cin >> w >> h;
  vector<vector<char> > horiz_picture(w, vector<char>(h));
  vector<vector<char> > result_picture(2 * w, vector<char>(2 * h));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> horiz_picture[j][i];
    }
  }
  for (int x = 0; x < w; ++x) {
    for (int y = 0; y < h; ++y) {
      result_picture[x * 2][y * 2] = horiz_picture[x][y];
      result_picture[x * 2][y * 2 + 1] = horiz_picture[x][y];
      result_picture[x * 2 + 1][y * 2] = horiz_picture[x][y];
      result_picture[x * 2 + 1][y * 2 + 1] = horiz_picture[x][y];
    }
  }
  print_picture(result_picture);
  return 0;
}
