#include <bits/stdc++.h>
using namespace std;
char s[110][110], ans[500][500];
int m, n;
void change() {
  int p = m, q = 1;
  while (p > q) {
    swap(s[p], s[q]);
    p--, q++;
  }
  swap(m, n);
  char temp[110][110];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) temp[i][j] = s[j][i];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) s[i][j] = temp[i][j];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%s", s[i] + 1);
  change();
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      ans[i * 2 - 1][j * 2 - 1] = ans[i * 2 - 1][j * 2] =
          ans[i * 2][j * 2 - 1] = ans[i * 2][j * 2] = s[i][j];
  m *= 2, n *= 2;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j < n - j + 1; j++) swap(ans[i][n - j + 1], ans[i][j]);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) putchar(ans[i][j]);
    puts("");
  }
  return 0;
}
