#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char s[N][N];
int n, m;
int main() {
  cin >> m >> n;
  for (int i = 1; i <= n; ++i) cin >> s[i] + 1;
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) cout << s[j][i] << s[j][i];
    cout << endl;
    for (int j = 1; j <= n; ++j) cout << s[j][i] << s[j][i];
    cout << endl;
  }
  return 0;
}
