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