while True:
try:
t,n=list(map(int,input().split()))
stri=""
for i in range(t):
stri=(stri+input())
x=list(map(int,input().split()))
for j in x:
print(stri[j-1],end='')
k=input()
except EOFError:
break
for j in x:
print(stri[j-1],end='')
k=input()
for j in x:
print(stri[j-1],end='')
k=input()
- 全部輸出完要換行
- 這行刪掉
感謝