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