while True:
try:
m, n = map(int, input().split())
if m == 0 and n == 0:
break
s = []
for i in range(m):
a = input()
s.append(a)
b = ''.join(s)
p = list(map(int, input().split()))
for k in p:
print(b[k-1], end='')
except:
break
我在編譯器內輸出是doomsday 但是到ZJ上就變成其他答案🛐🛐