Mathison recently inherited an ancient papyrus that contained some text. Unfortunately, the text was not a
pangram. Now, Mathison has a particular liking for holoalphabetic strings and the text bothers him. The good news is that Mathison can buy letters from the local store in order to turn his text into a pangram.

However, each letter has a price and Mathison is not very rich. Can you help Mathison find the cheapest way to obtain a pangram?

-----Input-----
The first line of the input file will contain one integer, T, representing the number of tests.
Each test will be formed from two lines. The first one contains 26 space-separated integers, representing the prices of all letters.
The second will contain Mathison's initial text (a string of N lowercase letters).

-----Output-----
The output file will contain T lines, one for each test. Each line will contain the answer for the corresponding test.

-----Constraints and notes-----
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 50,000
- All prices are natural numbers between 1 and 1,000,000 (i.e. 106).
- A pangram is a string that contains every letter of the Latin alphabet at least once.
- All purchased letters are added to the end of the string.

-----Subtaks-----
Subtask #1 (30 points):

- N = 1

Subtask #2 (70 points):

- Original constraints

-----Example-----
Input:
2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
abcdefghijklmopqrstuvwz
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
thequickbrownfoxjumpsoverthelazydog

Output:
63
0

-----Explanation-----
First test
There are three letters missing from the original string: n (price 14), x (price 24), and y (price 25).
Therefore the answer is 14 + 24 + 25 = 63.

Second test
No letter is missing so there is no point in buying something. The answer is 0.

Starter code:

Solutions:
# cook your dish here
# cook your dish here
for i in range(int(input())):
 a=list(map(int,input().split()))
 x=input()
 t=0
 for i in range(ord('a'),ord('z')+1):
  if chr(i) not in x:
   t+=a[i-97]
 print(t)

t=int(input())
x='abcdefghijklmnopqrstuvwxyz'
for i in range(t):
 a=0
 b=input().split()
 c=input()
 for j in range(len(x)):
  if(x[j] not in c):
   a=a+int(b[j])
 print(a)

t=int(input())
n="abcdefghijklmnopqrstuvwxyz"
for i in range(t):
 m=0
 p=input().split()
 q=input()
 for j in range(len(n)):
  if(n[j] not in q):
   m=m+int(p[j])
 print(m)

t=int(input())
a = "abcdefghijklmnopqrstuvwxyz"
for i in range(t):
 c=0
 p=input().split()
 s=input()
 
 for j in range(len(a)):
  if(a[j] not in s):
   c = c + int(p[j])
 print(c)


# cook your dish here
for i in range(int(input())):
 a=list(map(int,input().split()))
 x=input()
 t=0
 for i in range(97,123):
  if chr(i) not in x:
   t+=a[i-97]
 print(t)

# cook your dish here
for i in range(int(input())):
 a=list(map(int,input().split()))
 x=input()
 tot=0
 for i in range(97,123):
  if chr(i) not in x:
   tot+=a[i-97]
 print(tot)

# cook your dish here
for i in range(int(input())):
 a=list(map(int,input().split()))
 x=input()
 tot=0
 for i in range(ord('a'),ord('z')+1):
  if chr(i) not in x:
   tot+=a[i-97]
 print(tot)

# cook your dish here
t=int(input())
for i in range(t):
 arr = list(map(int,input().split()))
 s=input()
 brr=list(map(chr,range(97,123)))
 count=0
 for j in range(len(brr)):
  if brr[j] in s:
   continue
  else:
   count+=arr[j]
 print(count)

for _ in range(int(input())):
 A = list(map(int, input().split()))
 s, x = list(set(list(input()))), 0
 for c in s:
  x += A[ord(c)-97]
 print(sum(A)-x)

import string
check=string.ascii_lowercase
for _ in range(int(input())):
 price=0
 l=list(map(int,input().strip().split()))
 s=str(input())
 s=set(s)
 for i in range(0, len(check)):
  if check[i] not in s:
   price += l[i]
 print(price)

# cook your dish here
t = int(input())
for _ in range(t):
 price = list(map(int, input().split()))
 string = set(input())
 letters = []
 cost = 0
 for i in range(97, 123):
  if chr(i) not in string:
   cost += price[i-97]
 print(cost)


t = int(input())
for _ in range(t):
 price = list(map(int, input().split()))
 string = set(input())
 letters = []
 cost = 0
 for i in range(97, 123):
  if chr(i) not in string:
   cost += price[i-97]
 print(cost)


import bisect
from collections import Counter
for _ in range(int(input())):
 a=list(map(int,input().split()))
 s=input()
 c=0
 for i in range(ord('a'),ord('z')+1):
  if chr(i) not in s:
   c+=a[i-97]
 print(c)


for _ in range(int(input())):
 prices = list(map(int,input().split(' ')))
 s = set(input())
 total = 0
 for x in range(97,123):
  ch = chr(x)
  if ch not in s:
   total += prices[ord(ch)-97]
 print(total)


# cook your dish here
try:
 for i in range(int(input())):
  l=list(map(int,input().strip().split()))
  s=input()
  s=list(s)
  alpha="abcdefghijklmnopqrstuvwxyz"
  alpha=list(alpha)
  count=0
  for i in alpha:
   if i not in s:
    count=count+l[ord(i)-97]
  print(count)
except:
 pass


T = int(input())
for i in range(T):
 s = input()+' '
 cost = {}
 present = {}
 spend = 0
 for j in range(26):
  n = s.find(' ')
  cost[97+j] = int(s[:n])
  present[97+j] = False
  s = s[n+1:]
 s = input()
 for k in range(len(s)):
  t = ord(s[k])
  present[t] = True
 for l in range(26):
  if present[97+l] == False:
   spend += cost[97+l]
 print(spend)

# cook your dish here
t=int(input())
for i in range(t):
 alphabets='abcdefghijklmnopqrstuvwxyz'
 a=list(map(int,input().split()))
 s=input()
 c=0
 for j in alphabets:
  if j not in s:
   c+=a[ord(j)-97]
 print(c)

import string
s = string.ascii_lowercase
for _ in range(int(input())):
 arr = list(map(int, input().split()))
 s1 = input()
 total = 0
 for i in s:
  if i not in s1:
   total += arr[s.index(i)]
   s1 += i
 print(total)


import string
s = string.ascii_lowercase
for _ in range(int(input())):
 arr = list(map(int, input().split()))
 s1 = input()
 total = 0
 for i in s:
  if i not in s1:
   total += arr[s.index(i)]
   s1 += i
 print(total)