#include <bits/stdc++.h>
using namespace std;
const int MAXN = 35;
char brd[MAXN][MAXN];
string word[6];
int len[6], a[3], b[3], ai, bi;
bool tkn[6];
vector<pair<string, int> > S;
void autofill(const string &s, int x, int y, bool row) {
  if (row) {
    for (int i = (0); i < (s.size()); i++) {
      brd[x][y + i] = s[i];
    }
  } else {
    for (int i = (0); i < (s.size()); i++) {
      brd[x + i][y] = s[i];
    }
  }
}
void print() {
  bool flag;
  int len1 = 0, len2 = 0;
  for (int i = (0); i < (30); i++) {
    flag = false;
    for (int j = (0); j < (30); j++) {
      if (brd[i][j] != '.') {
        len2 = max(len2, j);
        flag = true;
      }
    }
    if (flag) {
      len1 = i;
    } else {
      break;
    }
  }
  for (int i = (0); i < (len1 + 1); i++) {
    for (int j = (0); j < (len2 + 1); j++) {
      cout << brd[i][j];
    }
    cout << '\n';
  }
  cout << '\n';
}
bool solve() {
  int au, am, ad, bl, bm, br;
  string aml, amr, bmu, bmd, tmp;
  for (int i = (0); i < (2); i++)
    for (int j = (0); j < (2); j++) {
      au = a[i];
      ad = a[i ^ 1];
      am = a[2];
      bl = b[j];
      br = b[j ^ 1];
      bm = b[2];
      if (word[au][0] == word[bl][0]) {
        if (word[au][len[au] - 1] == word[bm][0]) {
          if (word[am][0] == word[bl][len[bl] - 1]) {
            if (word[am][len[au] - 1] == word[bm][len[bl] - 1]) {
              if (word[am][len[am] - 1] == word[br][0]) {
                if (word[ad][0] == word[bm][len[bm] - 1]) {
                  if (word[ad][len[ad] - 1] == word[br][len[br] - 1]) {
                    if (word[au] > word[bl]) {
                      swap(au, bl);
                      swap(am, bm);
                      swap(ad, br);
                    }
                    if (len[au] == len[bl] &&
                        word[au][len[au] - 1] == word[bl][len[bl] - 1]) {
                      if (len[am] > len[bm]) {
                        swap(am, bm);
                        swap(ad, br);
                      } else if (len[am] == len[bm]) {
                        aml.assign(word[am], 0, len[au]);
                        amr.assign(word[am], len[au] - 1, len[ad]);
                        bmu.assign(word[bm], 0, len[bl]);
                        bmd.assign(word[bm], len[bl] - 1, len[br]);
                        if (aml < bmu) {
                          swap(am, bm);
                          swap(ad, br);
                        } else if (amr > bmu) {
                          swap(am, bm);
                          swap(ad, br);
                        }
                        if (word[ad][0] == word[br][0]) {
                          if (word[ad] < word[br]) {
                            swap(ad, br);
                          }
                        }
                      }
                    }
                    memset(brd, '.', sizeof(brd));
                    autofill(word[au], 0, 0, 1);
                    autofill(word[bl], 0, 0, 0);
                    autofill(word[am], len[bl] - 1, 0, 1);
                    autofill(word[bm], 0, len[au] - 1, 0);
                    autofill(word[ad], len[bm] - 1, len[au] - 1, 1);
                    autofill(word[br], len[bl] - 1, len[am] - 1, 0);
                    tmp.clear();
                    for (int k1 = (0); k1 < (len[bm]); k1++) {
                      for (int k2 = (0); k2 < (len[am]); k2++) {
                        tmp += brd[k1][k2];
                      }
                    }
                    S.push_back(make_pair(tmp, len[am]));
                  }
                }
              }
            }
          }
        }
      }
    }
  return false;
}
bool cmp(int a, int b) { return len[a] < len[b]; }
int main() {
  for (int i = (0); i < (6); i++) cin >> word[i];
  sort(word, word + 6);
  for (int i = (0); i < (6); i++) len[i] = word[i].size();
  memset(brd, '.', sizeof(brd));
  tkn[0] = true;
  for (int t2 = (1); t2 < (6); t2++) {
    tkn[t2] = true;
    for (int t3 = (t2 + 1); t3 < (6); t3++) {
      tkn[t3] = true;
      ai = 0, bi = 0;
      for (int i = (0); i < (6); i++) {
        if (tkn[i])
          a[ai++] = i;
        else
          b[bi++] = i;
      }
      sort(a, a + 3, cmp);
      sort(b, b + 3, cmp);
      tkn[t3] = false;
      if (len[a[2]] + 1 != len[a[0]] + len[a[1]]) continue;
      if (len[b[2]] + 1 != len[b[0]] + len[b[1]]) continue;
      if (solve()) {
        print();
        return 0;
      }
    }
    tkn[t2] = false;
  }
  if (S.empty()) {
    cout << "Impossible\n";
  } else {
    pair<string, int> mins = S[0];
    for (int i = (1); i < (S.size()); i++) {
      if (S[i].first < mins.first) {
        mins = S[i];
      }
    }
    for (int i = (0); i < (mins.first.size()); i++) {
      if (!(i % mins.second)) cout << '\n';
      cout << mins.first[i];
    }
  }
  return 0;
}
