# # # data = [[0 for i in range(27)]*27]
# # # arr = []
# # # for i in range(1, 26):
# # # v = list(map(int, input().split()))
# # # v.append (0)
# # # arr.append(v)
# # # data.append([0 for i in range(25)])
# # #
# # # print(len(arr),len(arr[0]))
# # #
# # # f = 0
# # # for i in range(1, 26):
# # # for j in range(1, 26):
# # # f = arr[i-1][j-1] + arr[i-1][j] + arr[i-1][j+1] + arr[i][j-1] + arr[i][j+1] + arr[i+1][j-1] + arr[i+1][j] + arr[i+1][j+1]
# # # if arr[i][j] == 0:
# # # if f==3:
# # # arr[i][j] = 1
# # # elif arr[i][j] == 1:
# # # if f==3 or f==2:
# # # arr[i][j] = 1
# # # elif f>=4 or f<=1:
# # # arr[i][j] = 0
# # #
# # # for i in range(1, 26):
# # # for j in range(1, 26):
# # # print(arr[i][j], end = ' ')
# # # print()
# #
# # data = [[0 for i in range(1001)]*1001]
# # count = 0
# # n = 1
# # a, b = map(int, input().split())
# # data[0][0] = 1
# # for i in range(1, b):
# # t = 1
# # for j in range(1, data[i][j]!=0):
# # if data[i][j] == data[i][j+1]:
# # count+=1
# # else:
# # data[i+1][t] = data[i][j]
# # data[i+1][t+1] = count
# # count = 1
# # t+=2
# #
# # for i in range(a+1, b+2):
# # for j in range(1, len(data)):
# # print(data[i][j])
# # print()
#
# def life(x, y):
# # x,y의 주변 8칸의 생명의 갯수
# global data
#
# sum = 0
# if x - 1 > 0 and y - 1 > 0 and data[x - 1][y - 1] == 1:
# sum += 1
# if x - 1 > 0 and data[x - 1][y] == 1:
# sum += 1
# if x - 1 > 0 and y + 1 < 26 and data[x - 1][y + 1] == 1:
# sum += 1
# if y + 1 < 26 and data[x][y + 1] == 1:
# sum += 1
# if y - 1 > 0 and data[x][y - 1] == 1:
# sum += 1
# if x + 1 < 26 and y + 1 < 26 and data[x + 1][y + 1] == 1:
# sum += 1
# if x + 1 < 26 and y - 1 > 0 and data[x + 1][y - 1] == 1:
# sum += 1
# if x + 1 < 26 and data[x + 1][y] == 1:
# sum += 1
# return sum
#
# data1 = [[0]*26 for i in range(26)]
#
# data = [[0 for i in range(26)] * 26]
# for i in range(1, 26):
# v = list(map(int, input().split()))
# v.insert(0, 0)
# v.append(0)
# data.append(v)
# data.append([0 for i in range(26)])
#
# for i in range(1, 26):
# for j in range(1, 26):
# if life(i, j) == 3 and data[i][j] == 0:
# data1[i][j] = 1
# elif life(i, j) >= 4 and data[i][j] == 1:
# data1[i][j] = 0
# elif life(i, j) <= 1 and data[i][j] == 1:
# data1[i][j] = 0
# elif life(i, j) == 2 and data[i][j] == 1:
# data1[i][j] = 1
# elif life(i, j) == 3 and data[i][j] == 1:
# data1[i][j] = 1
# else:
# data1[i][j] = 0
#
#
# for i in range(1, 26):
# for j in range(1, 26):
# print(data1[i][j], end=' ')
# print()
# a, b = map(int, input().split())
# num = [[0] * 26 for i in range(26)]]
# num[0][0] = 1
# for i in range():
# for j in range():
# if num[i][j] == num [i][j]
# for i in range():
# for j in range(a, b):
# data = [[0 for i in range(27)]*27]
# arr = []
# for i in range(1, 26):
# v = list(map(int, input().split()))
# v.append (0)
# arr.append(v)
# data.append([0 for i in range(25)])
#
# print(len(arr),len(arr[0]))
#
# f = 0
# for i in range(1, 26):
# for j in range(1, 26):
# f = arr[i-1][j-1] + arr[i-1][j] + arr[i-1][j+1] + arr[i][j-1] + arr[i][j+1] + arr[i+1][j-1] + arr[i+1][j] + arr[i+1][j+1]
# if arr[i][j] == 0:
# if f==3:
# arr[i][j] = 1
# elif arr[i][j] == 1:
# if f==3 or f==2:
# arr[i][j] = 1
# elif f>=4 or f<=1:
# arr[i][j] = 0
#
# for i in range(1, 26):
# for j in range(1, 26):
# print(arr[i][j], end = ' ')
# print()
'''
count = 1
data = []
n = 1
a, b = map(int, input().split())
data.append([1]);
for i in range(0, b-1):
t = 1
j=0
d=[]
while len(data[i])>j:
if j+1 < len(data[i]) and data[i][j] == data[i][j+1]:
count+=1
else:
d.append(data[i][j])
d.append(count)
count = 1
t+=2
j+=1
data.append(d)
for i in range(a-1, b):
for j in range(0, len(data[i])):
print(data[i][j],end=' ')
print()
'''
#water_balloon - 장애물 역할 (함수)
#obstacle - 빠지면 죽음 (water_balloon)과 유사 (함수)
#player - Character Information 아래에 번호 매겨야 함 (정수 자료형)
map = [list(map(int, input().split()))for i in range(10)]
n = int(input())
a = []*n
for i in range(n):
a.append(input().split())
def water_balloon(a, b):
global map
def obstacle(a, b):
global map
for i in range(10):
for j in range(10):
if map[i][j]>0:
balloon = map[i][j]
map[i][j] = -2
for k in range(balloon):
if i+k>10 or map[i+k][j] == -1:
break
if map[i+k][j] == 0:
map[i+k][j] = -2
for k in range(balloon):
if i-k>10 or map[i-k][j] == -1:
break
if map[i-k][j] == 0:
map[i-k][j] = -2
for k in range(balloon):
if j-k>10 or map[i][j-k] == -1:
break
if map[i][j-k] == 0:
map[i][j-k] = -2
for k in range(balloon):
if j+k>10 or map[i][j+k] == -1:
break
if map[i][j+k] == 0:
map[i][j+k] = -2
for i in range(player):
if map[x[i]][y[i]]!=-2:
map[x[i]][y[i]] = i
for i in range(10):
for j in range(10):
print(map[i][j], end = ' ')
print()
print("Character Information")
for i in range(player):
if map[x[i]][y[i]] == -2:
print("player ", i, " dead", sep = '')
else:
print("player ", i, " survive", sep = '')