#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> m >> n;
  char table[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> table[i][j];
    }
  }
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      char a = table[i][j];
      cout << a << a;
    }
    cout << endl;
    for (int i = 0; i < n; i++) {
      char a = table[i][j];
      cout << a << a;
    }
    cout << endl;
  }
  return 0;
}
