#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[100][100];
int main() {
  cin >> m >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[j][i];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cout << a[i][j] << a[i][j];
    }
    cout << "\n";
    for (int j = 0; j < n; j++) {
      cout << a[i][j] << a[i][j];
    }
    cout << "\n";
  }
  return 0;
}
