def check():
tmp=[]
for i in range(n-1,-1,-1):
if stat[i]=="0":
tmp.insert(0,key[i])
else:
tmp.append(key[i])
return tmp
times,n=map(int,input().split())
stats=[]
for _ in range(times):
stats.append(input())
key=input()
for j in range(times-1,-1,-1):
stat=list(stats[j])
key=check()
if stat.count("1")%2==1:
if n%2==0:
lol=int(n/2)
list1,list2=key[lol:n],key[0:lol]
key=list1+list2
else:
lol=int((n+1)/2)
list1,list2,list3=key[lol:n],key[lol-1],key[0:lol-1]
key=list1+list(list2)+list3
print(*key,sep="")