d=[[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]

def f(x,y,a):

    a[y][x]='0'

    for dx,dy in d:

        if 0<=x+dx<8 and 0<=y+dy<8 and a[y+dy][x+dx]=='1':f(x+dx,y+dy,a)

    return a



for i in range(int(eval(input()))):

    print(('Data %d:'%(i+1)))

    eval(input())

    a=[list(eval(input())) for _ in [0]*8]

    for x in f(int(eval(input()))-1,int(eval(input()))-1,a):print((''.join(x)))
def f(x,y,a):

    a[y][x]='0'

    for dx,dy in [[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]:

        if 0<=x+dx<8 and 0<=y+dy<8 and a[y+dy][x+dx]=='1':f(x+dx,y+dy,a)

    return a



for i in range(int(input())):

    print('Data %d:'%(i+1))

    input()

    a=[list(input()) for _ in [0]*8]

    [print(*x,sep='')for x in f(int(input())-1,int(input())-1,a)]

d = [
    [-3, 0],
    [-2, 0],
    [-1, 0],
    [1, 0],
    [2, 0],
    [3, 0],
    [0, -3],
    [0, -2],
    [0, -1],
    [0, 1],
    [0, 2],
    [0, 3],
]


def f(x, y, a):
    a[y][x] = "0"
    for dx, dy in d:
        if 0 <= x + dx < 8 and 0 <= y + dy < 8 and a[y + dy][x + dx] == "1":
            f(x + dx, y + dy, a)
    return a


for i in range(int(eval(input()))):
    print(("Data %d:" % (i + 1)))
    eval(input())
    a = [list(eval(input())) for _ in [0] * 8]
    for x in f(int(eval(input())) - 1, int(eval(input())) - 1, a):
        print(("".join(x)))

def f(x, y, a):
    a[y][x] = "0"
    for dx, dy in [
        [-3, 0],
        [-2, 0],
        [-1, 0],
        [1, 0],
        [2, 0],
        [3, 0],
        [0, -3],
        [0, -2],
        [0, -1],
        [0, 1],
        [0, 2],
        [0, 3],
    ]:
        if 0 <= x + dx < 8 and 0 <= y + dy < 8 and a[y + dy][x + dx] == "1":
            f(x + dx, y + dy, a)
    return a


for i in range(int(input())):
    print("Data %d:" % (i + 1))
    input()
    a = [list(input()) for _ in [0] * 8]
    [print(*x, sep="") for x in f(int(input()) - 1, int(input()) - 1, a)]

-d = [ -    [-3, 0], -    [-2, 0], -    [-1, 0], -    [1, 0], -    [2, 0], -    [3, 0], -    [0, -3], -    [0, -2], -    [0, -1], -    [0, 1], -    [0, 2], -    [0, 3], -] - - -    for dx, dy in d: +    for dx, dy in [ +        [-3, 0], +        [-2, 0], +        [-1, 0], +        [1, 0], +        [2, 0], +        [3, 0], +        [0, -3], +        [0, -2], +        [0, -1], +        [0, 1], +        [0, 2], +        [0, 3], +    ]: -for i in range(int(eval(input()))): -    print(("Data %d:" % (i + 1))) -    eval(input()) -    a = [list(eval(input())) for _ in [0] * 8] -    for x in f(int(eval(input())) - 1, int(eval(input())) - 1, a): -        print(("".join(x))) +for i in range(int(input())): +    print("Data %d:" % (i + 1)) +    input() +    a = [list(input()) for _ in [0] * 8] +    [print(*x, sep="") for x in f(int(input()) - 1, int(input()) - 1, a)]