You are given strings and required to find the length of the longest perfect word.
A string is called a perfect word, if and only if every non-empty substring of appears in the given strings.
A string is called a substring of if and only if it can be obtained by removing several (possibly zero) characters from the beginning or end of .