func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, s, f, l, r, t;   int stay() {     int next = (s < f) ? s + 1 : s - 1;     return (s >= l && s <= r) || (next >= l && next <= r);   }   int di[] = {0, 1};   int dj[] = {1, 0};   void write(vector<string> &res, int x, int y, int dir, string s) {     for (int i = 0; i < s.size(); i++) {       res[x][y] = s[i];       x += di[dir];       y += dj[dir];     }   }   void print(vector<string> res) {     for (int i = 0; i < res.size(); i++) {       for (int j = 0; j < res[i].size(); ++j) {         cout << res[i][j];       }       cout << endl;     }   }   bool same(string a, string b, int i, int j) { return a[i] == b[j]; }   int main() {     vector<string> arr(6);     vector<bool> vis(6, 0);     for (int i = 0; i < 6; ++i) {       cin >> arr[i];     }     sort(arr.begin(), arr.end());     vector<string> best, res;     do {       if (!same(arr[0], arr[1], 0, 0) ||           !same(arr[4], arr[5], arr[4].size() - 1, arr[5].size() - 1))         continue;       if (arr[3].size() != arr[0].size() + arr[4].size() - 1 ||           arr[2].size() != arr[1].size() + arr[5].size() - 1)         continue;       if (!same(arr[3], arr[2], arr[0].size() - 1, arr[1].size() - 1) ||           !same(arr[2], arr[0], 0, arr[0].size() - 1) ||           !same(arr[2], arr[4], arr[2].size() - 1, 0))         continue;       if (!same(arr[3], arr[1], 0, arr[1].size() - 1) ||           !same(arr[3], arr[5], arr[3].size() - 1, 0))         continue;       int n = arr[2].size(), m = arr[3].size();       string tmp = string(m,  . );       res = vector<string>(n, tmp);       write(res, 0, 0, 0, arr[0]);       write(res, 0, 0, 1, arr[1]);       write(res, 0, arr[0].size() - 1, 1, arr[2]);       write(res, arr[1].size() - 1, 0, 0, arr[3]);       write(res, n - 1, arr[0].size() - 1, 0, arr[4]);       write(res, arr[1].size() - 1, m - 1, 1, arr[5]);       if (!best.size() || best > res) best = res;     } while (next_permutation(arr.begin(), arr.end()));     if (!best.size())       cout <<  Impossible  << endl;     else       print(best);     return 0;   }   