#include <bits/stdc++.h>
using namespace std;
int f_max(int x, int y) { return x > y ? x : y; }
int f_min(int x, int y) { return x < y ? x : y; }
void f_swap(int &x, int &y) {
  int t;
  t = x, x = y, y = t;
}
int f_abs(int x) { return x > 0 ? x : -x; }
char s[100][100];
char ans[100][100];
int l, r;
char tmp[100][100];
int arr[100];
int len[100];
int main() {
  int i, j;
  int tt = 6;
  l = r = -1;
  for (i = 0; i < 6; i++) scanf("%s", s[i]);
  for (i = 0; i < 6; i++) arr[i] = i;
  do {
    for (i = 0; i < 6; i++) len[i] = strlen(s[arr[i]]);
    if (len[0] + len[1] - 1 != len[2]) continue;
    if (len[3] + len[4] - 1 != len[5]) continue;
    if (s[arr[0]][0] != s[arr[3]][0]) continue;
    if (s[arr[0]][len[0] - 1] != s[arr[5]][0]) continue;
    if (s[arr[3]][len[3] - 1] != s[arr[2]][0]) continue;
    if (s[arr[2]][len[2] - 1] != s[arr[4]][0]) continue;
    if (s[arr[4]][len[4] - 1] != s[arr[1]][len[1] - 1]) continue;
    if (s[arr[5]][len[5] - 1] != s[arr[1]][0]) continue;
    if (s[arr[5]][len[3] - 1] != s[arr[2]][len[0] - 1]) continue;
    int nn = 0;
    for (i = 0; i < len[5]; i++) {
      for (j = 0; j < len[2]; j++) {
        tmp[i][j] = '.';
        nn++;
      }
      tmp[i][j] = 0;
    }
    for (i = 0; i < len[0]; i++) tmp[0][i] = s[arr[0]][i];
    for (i = 0; i < len[1]; i++) tmp[len[5] - 1][len[0] - 1 + i] = s[arr[1]][i];
    for (i = 0; i < len[2]; i++) tmp[len[3] - 1][i] = s[arr[2]][i];
    for (i = 0; i < len[3]; i++) tmp[i][0] = s[arr[3]][i];
    for (i = 0; i < len[4]; i++) tmp[len[3] - 1 + i][len[2] - 1] = s[arr[4]][i];
    for (i = 0; i < len[5]; i++) tmp[i][len[0] - 1] = s[arr[5]][i];
    if (l == -1) {
      for (i = 0; i < len[5]; i++) {
        for (j = 0; j <= len[2]; j++) {
          ans[i][j] = tmp[i][j];
        }
      }
      l = len[5], r = len[2];
    } else {
      int f = 0;
      for (i = 0; i < len[5] && i < l; i++) {
        if (strcmp(tmp[i], ans[i]) > 0) {
          f = -1;
          break;
        } else if (strcmp(tmp[i], ans[i]) < 0) {
          f = 1;
          break;
        }
      }
      if (f == 0) {
        if (i != l) {
          for (i = 0; i < len[5]; i++) {
            for (j = 0; j <= len[2]; j++) {
              ans[i][j] = tmp[i][j];
            }
          }
          l = len[5], r = len[2];
        }
      } else if (f == 1) {
        for (i = 0; i < len[5]; i++) {
          for (j = 0; j <= len[2]; j++) {
            ans[i][j] = tmp[i][j];
          }
        }
        l = len[5], r = len[2];
      }
    }
  } while (next_permutation(arr, arr + 6));
  if (l == -1)
    printf("Impossible\n");
  else
    for (i = 0; i < l; i++) printf("%s\n", ans[i]);
  return 0;
}

### Prompt

Your task is to create a Cpp solution to the following problem:

Vasya trains to compose crossword puzzles. He can only compose crosswords of a very simplе type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left to the right horizontally. The words are arranged in the form of a rectangular "eight" or infinity sign, not necessarily symmetrical.

The top-left corner of the crossword coincides with the top-left corner of the rectangle. The same thing is correct for the right-bottom corners. The crossword can't degrade, i.e. it always has exactly four blank areas, two of which are surrounded by letters. Look into the output for the samples for clarification.

Help Vasya — compose a crossword of the described type using the given six words. It is allowed to use the words in any order.

Input

Six lines contain the given words. Every word consists of no more than 30 and no less than 3 uppercase Latin letters. 

Output

If it is impossible to solve the problem, print Impossible. Otherwise, print the sought crossword. All the empty squares should be marked as dots.

If there can be several solutions to that problem, print the lexicographically minimum one. I.e. the solution where the first line is less than the first line of other solutions should be printed. If the two lines are equal, compare the second lines and so on. The lexicographical comparison of lines is realized by the < operator in the modern programming languages.

Examples

Input

NOD
BAA
YARD
AIRWAY
NEWTON
BURN


Output

BAA...
U.I...
R.R...
NEWTON
..A..O
..YARD


Input

AAA
AAA
AAAAA
AAA
AAA
AAAAA


Output

AAA..
A.A..
AAAAA
..A.A
..AAA


Input

PTC
JYNYFDSGI
ZGPPC
IXEJNDOP
JJFS
SSXXQOFGJUZ


Output

JJFS....
Y..S....
N..X....
Y..X....
F..Q....
D..O....
S..F....
G..G....
IXEJNDOP
...U...T
...ZGPPC

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int f_max(int x, int y) { return x > y ? x : y; }
int f_min(int x, int y) { return x < y ? x : y; }
void f_swap(int &x, int &y) {
  int t;
  t = x, x = y, y = t;
}
int f_abs(int x) { return x > 0 ? x : -x; }
char s[100][100];
char ans[100][100];
int l, r;
char tmp[100][100];
int arr[100];
int len[100];
int main() {
  int i, j;
  int tt = 6;
  l = r = -1;
  for (i = 0; i < 6; i++) scanf("%s", s[i]);
  for (i = 0; i < 6; i++) arr[i] = i;
  do {
    for (i = 0; i < 6; i++) len[i] = strlen(s[arr[i]]);
    if (len[0] + len[1] - 1 != len[2]) continue;
    if (len[3] + len[4] - 1 != len[5]) continue;
    if (s[arr[0]][0] != s[arr[3]][0]) continue;
    if (s[arr[0]][len[0] - 1] != s[arr[5]][0]) continue;
    if (s[arr[3]][len[3] - 1] != s[arr[2]][0]) continue;
    if (s[arr[2]][len[2] - 1] != s[arr[4]][0]) continue;
    if (s[arr[4]][len[4] - 1] != s[arr[1]][len[1] - 1]) continue;
    if (s[arr[5]][len[5] - 1] != s[arr[1]][0]) continue;
    if (s[arr[5]][len[3] - 1] != s[arr[2]][len[0] - 1]) continue;
    int nn = 0;
    for (i = 0; i < len[5]; i++) {
      for (j = 0; j < len[2]; j++) {
        tmp[i][j] = '.';
        nn++;
      }
      tmp[i][j] = 0;
    }
    for (i = 0; i < len[0]; i++) tmp[0][i] = s[arr[0]][i];
    for (i = 0; i < len[1]; i++) tmp[len[5] - 1][len[0] - 1 + i] = s[arr[1]][i];
    for (i = 0; i < len[2]; i++) tmp[len[3] - 1][i] = s[arr[2]][i];
    for (i = 0; i < len[3]; i++) tmp[i][0] = s[arr[3]][i];
    for (i = 0; i < len[4]; i++) tmp[len[3] - 1 + i][len[2] - 1] = s[arr[4]][i];
    for (i = 0; i < len[5]; i++) tmp[i][len[0] - 1] = s[arr[5]][i];
    if (l == -1) {
      for (i = 0; i < len[5]; i++) {
        for (j = 0; j <= len[2]; j++) {
          ans[i][j] = tmp[i][j];
        }
      }
      l = len[5], r = len[2];
    } else {
      int f = 0;
      for (i = 0; i < len[5] && i < l; i++) {
        if (strcmp(tmp[i], ans[i]) > 0) {
          f = -1;
          break;
        } else if (strcmp(tmp[i], ans[i]) < 0) {
          f = 1;
          break;
        }
      }
      if (f == 0) {
        if (i != l) {
          for (i = 0; i < len[5]; i++) {
            for (j = 0; j <= len[2]; j++) {
              ans[i][j] = tmp[i][j];
            }
          }
          l = len[5], r = len[2];
        }
      } else if (f == 1) {
        for (i = 0; i < len[5]; i++) {
          for (j = 0; j <= len[2]; j++) {
            ans[i][j] = tmp[i][j];
          }
        }
        l = len[5], r = len[2];
      }
    }
  } while (next_permutation(arr, arr + 6));
  if (l == -1)
    printf("Impossible\n");
  else
    for (i = 0; i < l; i++) printf("%s\n", ans[i]);
  return 0;
}

```