#include <bits/stdc++.h>
using namespace std;
const int INF = (-1u) / 2;
const long long int INF2 = (-1ull) / 2;
int a, b, i, d[1011000], j, k, n, m, timer = 0, l, r, x, y;
int cnt = 0, fl = 0, a2, a3 = -1000000, ans = 0;
string s[500], res;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  swap(n, m);
  for (i = 0; i < n; i++) cin >> s[i];
  x = 0;
  y = 0;
  for (j = 0; j < m; j++) {
    y = 0;
    res = "";
    for (i = 0; i < n; i++) {
      res += s[i][j];
      res += s[i][j];
      y++;
    }
    cout << res << endl << res << endl;
    x++;
  }
  return 0;
}
