#include <bits/stdc++.h>
using namespace std;
char board[105][105], temp[105][105];
int h, w;
int main() {
  cin >> w >> h;
  int j, i;
  for (i = 1; i <= h; ++i) scanf("%s", board[i] + 1);
  for (j = 1; j <= w; ++j)
    for (i = 1; i <= h; ++i) temp[j][h - i + 1] = board[i][j];
  for (i = 1; i <= w; ++i)
    for (j = 1; j <= h; ++j) board[i][j] = temp[i][h - j + 1];
  int k;
  for (i = 1; i <= w; ++i)
    for (k = 0; k < 2; ++k) {
      for (j = 1; j <= h; ++j) putchar(board[i][j]), putchar(board[i][j]);
      putchar('\n');
    }
}
