#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, m = 0;
  char ch;
  cin >> n >> m;
  vector<vector<char>> v;
  vector<char> temp_v;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> ch;
      temp_v.push_back(ch);
    }
    v.push_back(temp_v);
    temp_v.clear();
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k < 2; ++k) cout << v[j][i];
    }
    cout << endl;
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k < 2; ++k) cout << v[j][i];
    }
    cout << endl;
  }
  return 0;
}
