#include <bits/stdc++.h>
using namespace std;
void each_case(int t) {
  int n, m, i, j, k, tp;
  cin >> m >> n;
  string s[n];
  for (i = 0; i <= n - 1; i++) cin >> s[i];
  for (j = 0; j <= m - 1; j++) {
    for (tp = 0; tp <= 1; tp++) {
      for (i = 0; i <= n - 1; i++) {
        cout << s[i][j] << s[i][j];
      }
      cout << endl;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1, i;
  for (i = 1; i <= t; i++) each_case(i);
  return 0;
}
