#include <bits/stdc++.h>
using namespace std;
const int n = 6;
string s[6];
bool used[6];
vector<vector<string> > ans;
vector<vector<char> > grid;
vector<vector<char> > ansch;
inline bool cmp(string a, string b) { return a < b; }
inline void rec(string pre, vector<string> path) {
  if (path.size() == 6) {
    if (path[0][0] != path[5][0]) return;
    ans.push_back(path);
    return;
  }
  if (path.size() < 3) {
    for (int i = 0; i < n; i++)
      if (!used[i]) {
        if (s[i][0] == pre[pre.size() - 1]) {
          path.push_back(s[i]);
          used[i] = true;
          rec(s[i], path);
          used[i] = false;
          path.pop_back();
        }
      }
  } else if (path.size() == 3) {
    for (int i = 0; i < n; i++)
      if (!used[i]) {
        if (s[i][s[i].size() - 1] == pre[pre.size() - 1]) {
          path.push_back(s[i]);
          used[i] = true;
          rec(s[i], path);
          path.pop_back();
          used[i] = false;
        }
      }
  } else if (path.size() == 4 || path.size() == 5) {
    for (int i = 0; i < n; i++)
      if (!used[i]) {
        if (pre[0] == s[i][s[i].size() - 1]) {
          path.push_back(s[i]);
          used[i] = true;
          rec(s[i], path);
          path.pop_back();
          used[i] = false;
        }
      }
  }
  return;
}
inline void put(vector<string> final) {
  int row = final[1].size();
  int col = final[4].size();
  vector<char> emp;
  for (int i = 0; i < col; i++) emp.push_back('.');
  grid.resize(row, emp);
  for (int i = 0; i < final[0].size(); i++) grid[0][i] = final[0][i];
  for (int i = 0; i < final[1].size(); i++)
    grid[i][final[0].size() - 1] = final[1][i];
  for (int i = 0; i < final[2].size(); i++)
    grid[row - 1][final[0].size() + i - 1] = final[2][i];
  for (int i = 0; i < final[3].size(); i++)
    grid[row - final[3].size() + i][col - 1] = final[3][i];
  for (int i = 0; i < final[4].size(); i++)
    grid[final[5].size() - 1][i] = final[4][i];
  for (int i = 0; i < final[5].size(); i++) grid[i][0] = final[5][i];
}
int main() {
  for (int i = 0; i < n; i++) cin >> s[i];
  sort(s, s + n, cmp);
  vector<string> emp;
  for (int i = 0; i < n; i++) {
    used[i] = true;
    emp.push_back(s[i]);
    rec(s[i], emp);
    emp.pop_back();
    used[i] = false;
  }
  vector<string> final;
  bool found = false;
  for (int i = 0; i < ans.size(); i++) {
    if (ans[i][0].size() + ans[i][2].size() - 1 != ans[i][4].size()) continue;
    if (ans[i][3].size() + ans[i][5].size() - 1 != ans[i][1].size()) continue;
    if (ans[i][4][ans[i][0].size() - 1] != ans[i][1][ans[i][5].size() - 1])
      continue;
    if (!found) {
      put(ans[i]);
      ansch = grid;
      final = ans[i];
      found = true;
    } else {
      grid.clear();
      put(ans[i]);
      for (int x = 0; x < min(grid.size(), ansch.size()); x++) {
        if (grid[x] == ansch[x])
          continue;
        else if (grid[x] < ansch[x]) {
          final = ans[i];
          ansch.clear();
          ansch = grid;
          break;
        } else
          break;
      }
    }
  }
  if (final.size() == 0) {
    cout << "Impossible" << endl;
    return 0;
  }
  grid.clear();
  put(final);
  for (int i = 0; i < grid.size(); i++) {
    for (int j = 0; j < grid[i].size(); j++) cout << grid[i][j];
    cout << endl;
  }
  return 0;
}
