White Cloud has a rectangle carpet of . has a color and a cost . White Rabbit will choose a subrectangle of from and the color of each grid is , the cost of is the (maximum number in the corresponding subrectangle of ). Then is continuously translated and copied in an infinite times, that is, expand into an infinite new matrix, , which satisfies . White Rabbit must ensure that is a subrectangle of . You need to find the minimum cost way.
输入描述:
The first line of input contains two integers For the next line of lines, each line contains lowercase English characters, denoting . For the next line of lines, each line contains integers in range [0,1000000000], denoting .
choose subrectangle colorA[1...1][3...4]=ca, After copying unlimited copies colorC= cacacacaca ... cacacacaca ... cacacacaca ... cacacacaca ... cacacacaca ... ......... colorA is a subrectangle of colorC the cost is max(3,1)*(1+1)*(2+1).