#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, i, j, n;
  cin >> w >> h;
  char image[102][102] = {""};
  char rotate[102][102] = {""};
  for (i = h - 1; i >= 0; i--) cin >> image[i];
  for (i = 0; i < w; i++)
    for (j = h - 1; j >= 0; j--) rotate[i][h - 1 - j] = image[j][i];
  for (i = 0; i < w; i++)
    for (n = 1; n <= 2; n++) {
      for (j = 0; j < h; j++) cout << rotate[i][j] << rotate[i][j];
      cout << "\n";
    }
  return 0;
}
