#include <bits/stdc++.h>
using namespace ::std;
char A[105][105], B[105][105], C[105][105], D[2 * 105][2 * 105];
int main(void) {
  int a, b, aux;
  cin >> a >> b;
  for (int i = 0; i < b; i++)
    for (int j = 0; j < a; j++) cin >> A[i][j];
  for (int i = 0; i < a; i++)
    for (int j = 0; j < b; j++) B[i][j] = A[j][a - i - 1];
  for (int i = 0; i < a; i++)
    for (int j = 0; j < b; j++) C[i][j] = B[a - i - 1][j];
  for (int i = 0; i < 2 * a; i++)
    for (int j = 0; j < 2 * b; j++) D[i][j] = C[i / 2][j / 2];
  for (int i = 0; i < 2 * a; i++) {
    for (int j = 0; j < 2 * b; j++) cout << D[i][j];
    cout << endl;
  }
}
