#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = 1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + ch - 48;
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 10)
    putchar(x + 48);
  else
    write(x / 10), putchar(x % 10 + 48);
}
inline void writeln(long long x) {
  if (x < 0) putchar('-'), x = -x;
  write(x);
  putchar('\n');
}
char s[7][35], ans[35][35];
int len[7], r[7], vis[7], n, m;
bool flag;
inline void solve() {
  if (len[r[1]] + len[r[6]] - 1 != len[r[4]] ||
      len[r[2]] + len[r[5]] - 1 != len[r[3]])
    return;
  char p[35][35];
  memset(p, 0, sizeof p);
  if (s[r[1]][1] == s[r[2]][1]) {
    if (s[r[1]][len[r[1]]] == s[r[3]][1]) {
      if (s[r[3]][len[r[2]]] == s[r[4]][len[r[1]]] &&
          s[r[4]][1] == s[r[2]][len[r[2]]]) {
        if (s[r[4]][len[r[4]]] == s[r[5]][1]) {
          if (s[r[5]][len[r[5]]] == s[r[6]][len[r[6]]] &&
              s[r[6]][1] == s[r[3]][len[r[3]]]) {
            int n1 = len[r[3]], m1 = len[r[4]];
            for (int i = 1; i <= len[r[1]]; i++) p[1][i] = s[r[1]][i];
            for (int i = 1; i <= len[r[2]]; i++) p[i][1] = s[r[2]][i];
            for (int i = 1; i <= len[r[3]]; i++) p[i][len[r[1]]] = s[r[3]][i];
            for (int i = 1; i <= len[r[4]]; i++) p[len[r[2]]][i] = s[r[4]][i];
            for (int i = len[r[2]]; i <= len[r[3]]; i++)
              p[i][m1] = s[r[5]][i - len[r[2]] + 1];
            int k = 0;
            for (int i = m1 - len[r[6]] + 1; i <= m1; i++)
              k++, p[n1][i] = s[r[6]][k];
            if (!flag) {
              flag = 1;
              n = n1;
              m = m1;
              for (int i = 1; i <= n; i++)
                for (int j = 1; j <= m; j++) ans[i][j] = p[i][j];
              for (int i = 1; i <= n; i++)
                for (int j = 1; j <= m; j++)
                  if (!ans[i][j]) ans[i][j] = '.';
            } else {
              for (int i = 1; i <= n1; i++)
                for (int j = 1; j <= m1; j++)
                  if (!p[i][j]) p[i][j] = '.';
              bool g = 0, q = 0;
              for (int i = 1; i <= min(n1, n); i++) {
                if (i > n || g || q) break;
                for (int j = 1; j <= max(m1, m); j++) {
                  if (ans[i][j] > p[i][j]) {
                    g = 1;
                    break;
                  } else if (ans[i][j] < p[i][j]) {
                    q = 1;
                    break;
                  }
                }
              }
              if (g) {
                n = n1, m = m1;
                for (int i = 1; i <= n; i++)
                  for (int j = 1; j <= m; j++) ans[i][j] = p[i][j];
              }
            }
          }
        }
      }
    }
  }
}
inline void dfs(int x) {
  if (x == 7) solve();
  for (int i = 1; i <= 6; i++)
    if (!vis[i]) {
      vis[i] = 1;
      r[x] = i;
      dfs(x + 1);
      vis[i] = 0;
    }
}
int main() {
  for (int i = 1; i <= 6; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= 6; i++) len[i] = strlen(s[i] + 1);
  dfs(1);
  if (flag) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++)
        if (ans[i][j] != 0)
          cout << ans[i][j];
        else
          cout << ".";
      cout << endl;
    }
  } else
    puts("Impossible");
  return 0;
}
