#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:128777216")
using namespace std;
const long long LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
void prepare(string s) {
  if (s.length() != 0) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
  }
}
const int NMAX = 250;
int w, h;
char a[NMAX][NMAX], b[NMAX][NMAX];
void read() {
  scanf("%d %d\n", &w, &h);
  for (int i = 0; i < (int)(h); i++) scanf("%s", a[i]);
}
void solve() {
  for (int i = 0; i < (int)(h); i++)
    for (int j = 0; j < (int)(w); j++) b[j][h - i - 1] = a[i][j];
  swap(h, w);
  for (int i = 0; i < (int)(h); i++)
    for (int j = 0; j < (int)(w); j++) a[i][j] = b[i][j];
  for (int i = 0; i < (int)(h); i++)
    for (int j = 0; j < (int)(w / 2); j++) swap(a[i][j], a[i][w - j - 1]);
  for (int i = 0; i < (int)(h); i++) {
    for (int _ = 0; _ < (int)(2); _++) {
      for (int j = 0; j < (int)(w); j++) {
        printf("%c%c", a[i][j], a[i][j]);
      }
      printf("\n");
    }
  }
}
int main() {
  prepare("");
  read();
  solve();
  return 0;
}
