Problem Statement  
A Hamiltonian path in an undirected graph with N vertices is a sequence of vertices A_{1}, A_{2}, ..., A_{N} such that all A_{i} are pairwise distinct and for each i (1 < i &le N), there is an edge between vertices A_{i1} and A_{i}. A path starts at vertex A_{1} and visits each vertex of the sequence in order, ending at vertex A_{N}. The cost of a path is the sum of the weights of the edges connecting the path's consecutive vertices.
You're given a graph where the ith (0based) vertex is labeled with String label[i]. There is an edge between each pair of vertices. The cost of the edge between vertices i and j is equal to length^2 (label[i]) + length^2 (label[j])  length^2 (LCP (label[i], label[j]) ), where "^2" denotes squaring operation, length(X) is the length of string X and LCP(X,Y) is the longest common prefix of strings X and Y. Return the minimum possible cost of a Hamiltonian path which starts at vertex 0 and ends at vertex 1.  
Definition  
 
Notes  
  A prefix of string S is a string that can be obtained by removing zero or more contiguous characters from the end of S.  
  The longest common prefix of two strings A and B is the longest possible string which is a prefix of both A and B.  
Constraints  
  label will contain between 2 and 50 elements, inclusive.  
  Each element of label will be between 1 and 50 characters long, inclusive.  
  Each element of label will consist of lowercase letters ('a''z') only.  
Examples  
0)  
 
1)  
 
2)  
 
3)  
