A=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for Row in range(3):
        for Col in range(3):
            if b==A[Row][Col]:
                A[Row][Col]=0  

print(A)