#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  char c;
  cin >> n >> m;
  int a[m + 1][n + 1];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) {
      cin >> c;
      if (c == '.')
        a[i][j] = 0;
      else
        a[i][j] = 1;
    }
  int b[n + 1][m + 1];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) b[j][m - i - 1] = a[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m / 2; j++) swap(b[i][j], b[i][m - 1 - j]);
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < 2; k++) {
      for (int j = 0; j < m; j++)
        if (b[i][j])
          cout << "**";
        else
          cout << "..";
      cout << endl;
    }
  }
}
