#include <bits/stdc++.h>
using namespace std;
int N, M;
char A[1100][1100], B[1100][1100];
void print() {
  for (long long I = 1; I <= 2 * N; I++) {
    for (long long K = 1; K <= 2 * M; K++) cout << B[I][K];
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (long long I = 1; I <= M; I++)
    for (long long K = 1; K <= N; K++) {
      cin >> A[K][I];
    }
  for (long long I = 1; I <= N; I++)
    for (long long K = 1; K <= M; K++)
      B[2 * I][2 * K] = B[2 * I - 1][2 * K] = B[2 * I][2 * K - 1] =
          B[2 * I - 1][2 * K - 1] = A[I][K];
  print();
}
