#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int w, h;
    in >> w >> h;
    vector<string> m(h);
    for (string& s : m) in >> s;
    for (int i = 0; i < 2 * w; ++i) {
      for (int j = 0; j < 2 * h; ++j) out << m[j / 2][i / 2];
      out << "\n";
    }
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
