2-11
Source: hackerearth
Difficulty: EASY

Chotu is a student of IIIT-A and as its a tradition here he wants to copy his assignment on the last day, but to his horror it was a very long Code. His best friend Motu comes to his rescue and shows him his code. Chotu wants to copy the assignment as quickly as possible but due to the fear of being caught in plagirism check he decides to change all the variable names.
Changing one character to another takes some units of time, Chotu is running out of time so he asks you to calculate the minimum possible time in which he can change a given variable name to another.

NOTE: all the characters in a variable name are in LOWER CASE and the length of old and new variable names is equal for  all cases.

INPUT
First line of input contains N the number of variables to be changed.
Next 26 lines contain 26 integers each A(i, j), where the j^th integer on i^th line denotes the time taken to convert i^th character of english alphabet to j^th character.
Next follow 2xN lines containing the Old and the New variable names.
OUTPUT
For each input String output the minimum possible time for conversion.

CONSTRAINTS
1 ≤ N ≤ 100
1 ≤ A(i, j) ≤ 26
1 ≤ |S| ≤ 10^6

SAMPLE INPUT
2
0 1 1 2 1 1 2 1 1 3 3 1 3 1 2 2 1 2 1 1 1 1 3 1 1 1 
1 0 1 2 3 2 2 3 1 1 1 2 3 3 1 2 3 1 1 3 2 3 2 1 2 3 
1 1 0 3 2 3 2 1 3 3 3 2 2 1 3 1 1 3 2 3 1 3 2 1 2 1 
2 2 3 0 1 2 2 3 3 1 3 2 2 1 1 3 2 1 1 3 2 3 1 3 2 1 
1 3 2 1 0 3 3 2 3 3 2 1 2 1 3 3 3 2 3 1 3 1 2 1 1 2 
1 2 3 2 3 0 1 1 3 3 1 1 2 1 3 1 2 3 1 2 3 3 3 3 1 3 
2 2 2 2 3 1 0 1 2 2 2 2 1 1 1 3 1 2 3 3 1 1 2 2 1 1 
1 3 1 3 2 1 1 0 3 3 2 1 2 2 3 1 3 1 3 3 2 2 3 1 3 3 
1 1 3 3 3 3 2 3 0 3 1 1 1 2 2 3 3 1 1 3 2 3 3 1 1 2 
3 1 3 1 3 3 2 3 3 0 1 2 3 2 3 2 3 1 3 3 3 2 1 2 3 2 
3 1 3 3 2 1 2 2 1 1 0 3 1 1 3 1 1 3 2 1 1 1 2 3 2 3 
1 2 2 2 1 1 2 1 1 2 3 0 2 2 2 2 3 3 1 3 2 3 2 1 3 1 
3 3 2 2 2 2 1 2 1 3 1 2 0 2 2 3 1 1 1 3 3 1 2 1 2 2 
1 3 1 1 1 1 1 2 2 2 1 2 2 0 3 2 3 2 1 1 2 2 1 1 3 2 
2 1 3 1 3 3 1 3 2 3 3 2 2 3 0 3 2 3 1 1 3 1 3 3 1 3 
2 2 1 3 3 1 3 1 3 2 1 2 3 2 3 0 3 1 3 3 3 2 3 1 2 2 
1 3 1 2 3 2 1 3 3 3 1 3 1 3 2 3 0 3 3 1 3 3 2 1 2 2 
2 1 3 1 2 3 2 1 1 1 3 3 1 2 3 1 3 0 3 3 3 2 1 1 2 1 
1 1 2 1 3 1 3 3 1 3 2 1 1 1 1 3 3 3 0 1 3 1 2 1 3 3 
1 3 3 3 1 2 3 3 3 3 1 3 3 1 1 3 1 3 1 0 3 2 3 3 2 3 
1 2 1 2 3 3 1 2 2 3 1 2 3 2 3 3 3 3 3 3 0 2 2 2 2 1 
1 3 3 3 1 3 1 2 3 2 1 3 1 2 1 2 3 2 1 2 2 0 3 2 1 1 
3 2 2 1 2 3 2 3 3 1 2 2 2 1 3 3 2 1 2 3 2 3 0 3 2 3 
1 1 1 3 1 3 2 1 1 2 3 1 1 1 3 1 1 1 1 3 2 2 3 0 3 3 
1 2 2 2 1 1 1 3 1 3 2 3 2 3 1 2 2 2 3 2 2 1 2 3 0 2 
1 3 1 1 2 3 1 3 2 2 3 1 2 2 3 2 2 1 3 3 1 1 3 3 2 0 
arr
brr
inp
mat

SAMPLE OUTPUT
1
4

Explanation

For the first case 'a' in the old string can be converted to 'b' in 1 unit time and rest of the string remains the same.
For the second case i->m takes 1 unit time, n->a takes 1 unit time and p->f->t takes 2 units of time.