Problem list
Log in
#coci00220 · COCI 2011/2012 Contest 5

Križaljka

Bronze I 1.0 s 32 MB

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, A and B. The word A must be output horizontally, and the word B vertically, so that the two words cross (i.e. share exactly one letter). The shared letter must be the first letter in A that is also contained in B, more specifically the first occurrence of that letter in each word. For example, given the words A = “ABBA” and B = “CCBB”, you need to output 4 lines as shown below: .C.. .C.. ABBA .B..

Input

The first and only line of input contains two words, A and B, not more than 30 characters long, separated by a single space. Both words will contain only uppercase English letters. There will be at least one letter contained in both words.

Output

Let N be the length of word A, and M the length of word B. The output must contain M lines, each containing N characters. The character grid must contain the two words crossed as described above. All other characters in the grid must be periods (the character „.‟, without quotes), thus padding all lines to the length of N characters.

Example 1

Input
BANANA PIDZAMA
Output
.P....
.I....
.D....
.Z....
BANANA
.M....
.A....

Example 2

Input
MAMA TATA
Output
.T..
MAMA
.T..
.A..

Example 3

Input
REPUBLIKA HRVATSKA
Output
H........
REPUBLIKA
V........
A........
T........
S........
K........
A........
Source
COCI 2011/2012 Contest 5
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code