#include <bits/stdc++.h>
using namespace std;
char c[110][110];
int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < a; j++) cin >> c[j][i];
  }
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
      cout << c[i][j] << c[i][j];
    }
    cout << endl;
    for (int j = 0; j < b; j++) {
      cout << c[i][j] << c[i][j];
    }
    cout << endl;
  }
  return 0;
}
