#include <bits/stdc++.h>
int main() {
  int w, h;
  std::cin >> w >> h;
  std::vector<std::vector<std::pair<int, int>>> graph;
  std::vector<std::vector<int>> graph1;
  int maxi = std::max(2 * h, 2 * w);
  graph.resize(maxi);
  graph1.resize(maxi / 2);
  for (int i = 0; i < graph.size(); ++i) {
    for (int j = 0; j < maxi; ++j) {
      graph[i].push_back({-1, -1});
    }
  }
  for (int i = 0; i < graph1.size(); ++i) {
    for (int j = 0; j < maxi / 2; ++j) {
      graph1[i].push_back(-1);
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      char p;
      std::cin >> p;
      if (p == '.') {
        graph1[i][j] = 0;
      } else {
        graph1[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      graph[j][h - i - 1].first = graph1[i][j];
    }
  }
  for (int i = 0; i < w; ++i) {
    for (int j = 0; j < h / 2; ++j) {
      if (graph[i][j].first == graph[i][h - j - 1].first) continue;
      std::swap(graph[i][j].first, graph[i][h - j - 1].first);
    }
  }
  for (int i = 0; i < w; ++i) {
    for (int j = 0; j < h; ++j) {
      if (graph[i][j].first == 1) {
        graph[2 * i][2 * j].second = 1;
        graph[2 * i][2 * j + 1].second = 1;
        graph[2 * i + 1][2 * j].second = 1;
        graph[2 * i + 1][2 * j + 1].second = 1;
      } else {
        graph[2 * i][2 * j].second = 0;
        graph[2 * i][2 * j + 1].second = 0;
        graph[2 * i + 1][2 * j].second = 0;
        graph[2 * i + 1][2 * j + 1].second = 0;
      }
    }
  }
  for (int i = 0; i < 2 * w; ++i) {
    for (int j = 0; j < 2 * h; ++j) {
      if (graph[i][j].second == 0) {
        std::cout << ".";
      } else if (graph[i][j].second == 1) {
        std::cout << "*";
      }
    }
    std::cout << std::endl;
  }
  int qh;
  std::cin >> qh;
}
