Scientists of planet Olympia are conducting an experiment in mutation of primitive organisms. Genome of organism from this planet can be represented as a string of the first K capital English letters. For each pair of types of genes they assigned ai, j — a risk of disease occurence in the organism provided that genes of these types are adjacent in the genome, where i — the 1-ba
Scientists have already obtained a ba
Scientists want to find a number of different organisms that can be obtained from the given one which have the total risk of disease occurence not greater than T. They can use only the process of mutation described above. Two organisms are considered different if strings representing their genomes are different. Genome should contain at least one gene.
The first line of the input contains three integer numbers N (1 ≤ N ≤ 200 000) — length of the genome of ba
The third line contains K numbers t1, t2, ..., tK, where ti is additional risk value of disease occurence provided by removing of all genes of the i-th type.
The following K lines contain the elements of the given matrix ai, j. The i-th line contains K numbers. The j-th number of the i-th line stands for a risk of disease occurence for the pair of genes, first of which corresponds to the i-th letter and second of which corresponds to the j-th letter. The given matrix is not necessarily symmetrical.
All the numbers in the input are integer, non-negative and all of them except T are not greater than 109. It is guaranteed that the maximal possible risk of organism that can be obtained from the given organism is strictly smaller than 231.
5 3 13
BACAC
4 1 2
1 2 3
2 3 4
3 4 10
5