k,q,r=map(int,input().split())
s=input()#;print(s);
A= [[int(t) for t in input().split()] for _ in range(q)]#;print(A)
anss=[s]
for i in range(q):
news=[0]*k
t=0
for j in A[i]:
news[j-1]=anss[i][t]
t+=1
nexts=""#要加入的下一個字串
for u in range(len(news)):
nexts+=news[u]
anss.append(nexts)
#print(anss)
for i in range(r):
for j in range(1,len(anss)):
print(anss[j][i],end="")
print()