#include<bits/stdc++.h>
using namespace std;
#define MAX 100
int n,P[MAX];
string str;
void mult(bool A[MAX][MAX],bool B[MAX][MAX]){
bool res[MAX][MAX];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++){
res[i][j] = 0;
for(int k=0;k<n;k++)
res[i][j] = (res[i][j]|(A[i][k]&B[k][j]));
}
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
A[i][j] = res[i][j];
}
void init(bool A[MAX][MAX],bool res[MAX][MAX]){
// for(int i=0;i<n;i++)
// for(int j=0;j<n;j++)
// res[i][j] = A[i][j] = 0;
memset(res,0,sizeof(res));
memset(A,0,sizeof(A));
for(int i=0;i<n;i++)
A[P[i]][i] = 1,res[i][i] = 1;
}
void power(int b){
bool A[MAX][MAX],res[MAX][MAX];
init(A,res);
while(b){
if(b&1)
mult(res,A);
b/=2;
mult(A,A);
}
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(res[i][j])
cout << str[j];
cout << endl;
}
int main(){
while(1){
int m;
scanf("%d%d",&n,&m);
if(n==0 && m==0)
break;
for(int i=0;i<n;i++){
scanf("%d",&P[i]);
--P[i];
}
getchar();
getline(cin,str);
power(m);
str.clear();
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBNQVggMTAwCmludCBuLFBbTUFYXTsKc3RyaW5nIHN0cjsKdm9pZCBtdWx0KGJvb2wgQVtNQVhdW01BWF0sYm9vbCBCW01BWF1bTUFYXSl7CgoJYm9vbCByZXNbTUFYXVtNQVhdOwoKCWZvcihpbnQgaT0wO2k8bjtpKyspCgkJZm9yKGludCBqPTA7ajxuO2orKyl7CgkJCXJlc1tpXVtqXSA9IDA7CgkJCWZvcihpbnQgaz0wO2s8bjtrKyspCgkJCQlyZXNbaV1bal0gPSAocmVzW2ldW2pdfChBW2ldW2tdJkJba11bal0pKTsgCgkJfQoKCWZvcihpbnQgaT0wO2k8bjtpKyspCgkJZ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