#include <bits/stdc++.h>
using namespace std;
char a[511][511], b[511][511];
int n, m;
void rotate() {
  swap(n, m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      b[i][j] = a[j][i];
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) a[i][j] = b[i][j];
}
void mirror() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) swap(a[i][j], a[n - i - 1][j]);
}
int main() {
  scanf("%d%d\n", &m, &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) scanf("%c", &a[i][j]);
    scanf("\n");
  }
  rotate();
  mirror();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << a[i][j] << a[i][j];
    cout << "\n";
    for (int j = 0; j < m; j++) cout << a[i][j] << a[i][j];
    cout << "\n";
  }
  return 0;
}
