#include <bits/stdc++.h>
using namespace std;
const int MAX = 300;
const int MAXC = 15;
const int INF = 1e9;
const int MOD = 1000000007;
const double EPS = 1e-11;
int w, h;
int matr[MAX][MAX];
int matr2[MAX][MAX];
int main() {
  cin >> w >> h;
  char c;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> c;
      if (c == '.')
        matr[j][i] = false;
      else
        matr[j][i] = true;
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      matr2[h - i - 1][j] = matr[j][i];
    }
  }
  swap(h, w);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w / 2; ++j) {
      swap(matr2[j][i], matr2[w - j - 1][i]);
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      matr[2 * j][2 * i] = matr2[j][i];
      matr[2 * j + 1][2 * i] = matr2[j][i];
      matr[2 * j][2 * i + 1] = matr2[j][i];
      matr[2 * j + 1][2 * i + 1] = matr2[j][i];
    }
  }
  h *= 2;
  w *= 2;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (matr[j][i])
        cout << '*';
      else
        cout << '.';
    }
    cout << endl;
  }
}
