Since ACTA has entered into force, Slavko has been spending his time offline, solving crosswords. Having solved almost all that he could get his hands on, he wants to make a few crosswords of his own. However, he is too sloppy for such fine work, so he has asked you to help him generate the crosswords.
You are given two words, and
. The word
must be output horizontally, and the word
vertically, so that the two words cross (i.e. share exactly one letter). The shared letter must be the first
letter in
that is also contained in
, more specifically the first occurrence of that letter in each word.
For example, given the words
ABBA
and
CCBB
, you need to output lines as shown
below:
.C..
.C..
ABBA
.B..
Input Specification
The first and only line of input contains two words, and
, not more than
characters long,
separated by a single space. Both words contain only uppercase English letters. There will be at
least one letter contained in both words.
Output Specification
Let be the length of word
, and
the length of word
. The output must contain
lines, each
containing
characters. The character grid must contain the two words crossed as described above.
All other characters in the grid must be periods (
.
), thus padding all lines to the length of characters.
Sample Input 1
BANANA PIDZAMA
Sample Output 1
.P....
.I....
.D....
.Z....
BANANA
.M....
.A....
Sample Input 2
MAMA TATA
Sample Output 2
.T..
MAMA
.T..
.A..
Sample Input 3
REPUBLIKA HRVATSKA
Sample Output 3
H........
REPUBLIKA
V........
A........
T........
S........
K........
A........
Comments