#include <iostream>
using namespace std;
int main()
{
int number,b,c,total=0,p=10;
char first[]={0,'m','j','q','h','o','f','a','w','c','p','n','s','e','x','d','k','v','g','t','z','b','l','r','y','u','i'};
char second[]={0,'u','z','r','m','a','t','i','f','x','o','p','n','h','w','v','b','s','l','e','k','y','c','q','j','g','d'};
string h;
cin>>number;
for (int yo=0;yo<number;yo++)
{
cin>>c;
char a[c];
int b[c],j;
cin>>h;
if (char (h[0])>='a'&& char (h[0])<='z')
{
for (int top=1;top<=26;top++)
for (int i=0;i<c;i++)
if (char (h[i])==second[top])
total=total+top;
cout<<total;
total=0;
}
else
{
j=0;
b[0]=0;
for (int k=1;k<c;k++)
cin>>b[k];
while (1)
{
if (h[j]>=48 && h[j]<=58)
j++;
else
break;
}
if (j==2)
for (int y=0;y<j;y++)
{
b[0]=b[0]+(h[y]-48)*p;
p=1;
}
if (j==1)
b[0]=b[0]+(h[0]-48);
p=10;
for (int j=0;j<c;j++)
cout<<first[b[j]];
}
cout<<endl;
}
system ("pause");
return 0;
}