m, n = map(int, input().split())
str_e =[]
for i in range(0, m):
str_e.append(input())
str_t = input()
length = len(str_t)
temp_output = ""
for i in range(m):
temp_e = str_e.pop()
temp_num = 0
flag = False
for w in temp_e:
if int(w) == 1: temp_num += 1##
if temp_num % 2 != 0: flag = True
for j in temp_e[::-1]:
temp = str_t[-1] ##
str_t = str_t[:-1]
if int(j) == 0: ##
temp_output = temp + temp_output
else: temp_output = temp_output + temp
if flag:
middle = length // 2
if length % 2 != 0:
str_t = temp_output[middle+1:] + temp_output[middle] +temp_output[:middle]
else: str_t = temp_output[middle:] + temp_output[:middle]
else : str_t = temp_output
temp_output = ""
print(str_t)