#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long LINF = LLONG_MAX;
const unsigned long long ULINF = ULLONG_MAX;
const double EPS = 0.000001;
char v[150][150], v_new[150][150];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int w, h;
  cin >> w >> h;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) cin >> v[i][j];
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) v_new[j][i] = v[i][j];
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      cout << v_new[i][j];
      cout << v_new[i][j];
    }
    cout << "\n";
    for (int j = 0; j < h; j++) {
      cout << v_new[i][j];
      cout << v_new[i][j];
    }
    cout << "\n";
  }
  return 0;
}
