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