#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  vector<vector<char>> array(y, vector<char>(x));
  vector<vector<char>> output(2 * x, vector<char>(2 * y));
  char end;
  for (int j = 0; j < y; j++) {
    for (int i = 0; i < x; i++) {
      cin >> array[j][i];
    }
  }
  for (int j = 0; j < y; j++) {
    for (int i = 0; i < x; i++) {
      for (int k = 0; k <= 1; k++) {
        for (int l = 0; l <= 1; l++) {
          output[2 * i + k][2 * j + l] = array[j][i];
        }
      }
    }
  }
  for (int i = 0; i < 2 * x; i++) {
    for (int j = 0; j < 2 * y; j++) {
      cout << output[i][j];
    }
    cout << endl;
  }
  return 0;
}
