#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> m >> n;
  char** arr = (char**)malloc(sizeof(char*) * n);
  char** res = (char**)malloc(sizeof(char*) * (2 * m));
  for (int i = 0; i < n; i++) arr[i] = (char*)malloc(sizeof(char) * m);
  for (int i = 0; i < 2 * m; i++)
    res[i] = (char*)malloc(sizeof(char) * (2 * n));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      char c = arr[i][j];
      res[j * 2][i * 2] = c;
      res[(j * 2) + 1][i * 2] = c;
      int k = i * 2 + 1;
      for (int l = 0; l < 2 * m; l++) res[l][k] = res[l][k - 1];
    }
  for (int i = 0; i < 2 * m; i++) {
    for (int j = 0; j < 2 * n; j++) {
      cout << res[i][j];
    }
    cout << endl;
  }
  return 0;
}
