#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const long long INFL = (long long)9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const long long MAXLL = ((~0) ^ ((long long)1 << 63));
template <class T>
inline T pow2(T a) {
  return a * a;
}
template <class T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, true) : false;
}
template <class T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, true) : false;
}
const int maxn = (int)555;
;
char in[maxn][maxn], rot[maxn][maxn], grid[maxn][maxn];
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> m >> n;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++) cin >> in[i][j];
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++) rot[j][i] = in[i][j];
  swap(n, m);
  int di[] = {0, 0, 1, 1};
  int dj[] = {0, 1, 0, 1};
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(m); j++) {
      for (int k = 0; k < (int)(4); k++) {
        grid[2 * i + di[k]][2 * j + dj[k]] = rot[i][j];
      }
    }
  }
  for (int i = 0; i < (int)(2 * n); i++) {
    for (int j = 0; j < (int)(2 * m); j++) {
      cout << grid[i][j];
    }
    cout << endl;
  }
}
