#include <bits/stdc++.h>
using namespace std;
int n, a[100005], m;
char c[105][105], d[105][105];
int main() {
  cin >> m >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> c[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) d[m - j - 1][n - i - 1] = c[i][j];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n / 2; j++) swap(d[i][j], d[i][n - j - 1]);
  for (int i = m - 1; i >= 0; i--) {
    for (int j = 0; j < n; j++) cout << d[i][j] << d[i][j];
    cout << endl;
    for (int j = 0; j < n; j++) cout << d[i][j] << d[i][j];
    cout << endl;
  }
  cin >> n;
}
