Note: This is an approximate problem. There is no exact solution. You must find the most optimal solution. Refer to the sample explanation to ensure that you understand the problem correctly.
Problem statement
You are given N pattern strings. Find a string S that matches all the pattern strings.
A pattern string consists of lowercase Latin alphabets and * symbols. Each * may be replaced by any number of lowercase Latin characters. It is allowed to replace * with nothing, that is, remove the occurrence of * and concatenate the remaining strings.
A string S matches with a pattern string P, if there exists a way to achieve S from P by replacing * present in P.
Your task is to minimize the length of string S. (|S| ≤ 106)
Z = |S| is defined as the score of the test case.
Input format
Output format
Print a string that matches all the patterns.
Note: |S| should be less than equal to 106
Verdict and scoring
Constraints
N=100
500≤|P|≤1000
A solution to every test case always exist.
There is at least one '*' character in each pattern string.
String S = " raertaer" , can be generated from all the pattern strings.
Hence, Z = |S| = 8.
Note : Sample Test Case is for understanding purpose. Test Cases strictly follow the constraints provided.