#include <bits/stdc++.h>
using namespace std;
vector<vector<char> > rotate(vector<vector<char> > a) {
  long long n = a.size(), m = a[0].size();
  vector<vector<char> > A(m, vector<char>(n));
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < n; j++) {
      A[i][j] = a[n - 1 - j][i];
    }
  }
  return A;
}
vector<vector<char> > flip(vector<vector<char> > a) {
  long long m = a.size(), n = a[0].size();
  vector<vector<char> > A(m, vector<char>(n));
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < n; j++) {
      A[i][j] = a[i][n - 1 - j];
    }
  }
  return A;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  swap(n, m);
  vector<vector<char> > a(n, vector<char>(m));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  a = flip(rotate(a));
  swap(n, m);
  for (long long i = 0; i < n; i++) {
    for (long long x = 0; x < 2; x++) {
      for (long long j = 0; j < m; j++) {
        cout << a[i][j] << a[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}
