#include <bits/stdc++.h>
using namespace std;
int W, H;
string S[202], S2[202];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> W >> H;
  for (y = 0; y < H; y++) {
    cin >> S[y];
    for (x = 0; x < W; x++) S2[x] += S[y][x];
  }
  for (y = 0; y < W; y++) {
    for (x = 0; x < H; x++) cout << S2[y][x] << S2[y][x];
    cout << endl;
    for (x = 0; x < H; x++) cout << S2[y][x] << S2[y][x];
    cout << endl;
  }
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false);
  for (i = 0; i < argc - 1; i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < s.size(); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
