#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  cin >> w >> h;
  char char1[100][100], char2[100][100];
  string char3[200];
  for (int i(0); i < h; ++i) cin >> char1[i];
  for (int i(0); i < w; ++i) {
    for (int j(0); j < h; ++j) {
      char2[i][j] = char1[abs(j - h + 1)][i];
    }
  }
  for (int i(0); i < w; ++i) {
    for (int j(0); j < h / 2; ++j) {
      char tmp = char2[i][j];
      char2[i][j] = char2[i][abs(j - h + 1)];
      char2[i][abs(j - h + 1)] = tmp;
    }
  }
  for (int i(0); i < 2 * w; i += 2) {
    for (int j(0); j < h; ++j) {
      char3[i].insert(char3[i].end(), char2[i / 2][j]);
      char3[i].insert(char3[i].end(), char2[i / 2][j]);
    }
    char3[i + 1] = char3[i];
  }
  for (int i(0); i < 2 * w; ++i) cout << char3[i] << endl;
  return 0;
}
