#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int n, m;
char a[202][202], b[202][202], ans[202][202];
void show() {
  for (int i = 0; i < m; i++) {
    cout << '\n';
    for (int j = 0; j < n; j++) cout << b[i][j];
  }
  cout << '\n';
}
int main() {
  cin >> m >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) a[i][j] = s[j];
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) b[i][j] = a[n - 1 - j][i];
  swap(n, m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m / 2; j++) swap(b[i][j], b[i][m - 1 - j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      ans[2 * i][2 * j] = ans[2 * i][2 * j + 1] = ans[2 * i + 1][2 * j] =
          ans[2 * i + 1][2 * j + 1] = b[i][j];
  for (int i = 0; i < 2 * n; i++) {
    for (int j = 0; j < 2 * m; j++) cout << ans[i][j];
    cout << '\n';
  }
  return 0;
}
